int err;
msg_iovec_t iovec[msg_n_fragments] = {{ 0 }};
tport_ws_t *wstp = (tport_ws_t *)self;
- wsh_t *ws = wstp->ws;
- tport_ws_primary_t *wspri = (tport_ws_primary_t *)self->tp_pri;
uint8_t *data;
ws_opcode_t oc;
if (wstp->ws_initialized < 0) {
return -1;
- } else if (wstp->ws_initialized == 0) {
- if (ws_init(ws, self->tp_socket, 65336, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0) == -2) {
- return 2;
- }
- wstp->ws_initialized = 1;
- self->tp_pre_framed = 1;
- return 1;
}
- N = ws_read_frame(ws, &oc, &data);
+ N = ws_read_frame(&wstp->ws, &oc, &data);
if (N == -2) {
return 2;
size_t i, j, n, m, size = 0;
ssize_t nerror;
tport_ws_t *wstp = (tport_ws_t *)self;
- wsh_t *ws = wstp->ws;
enum { WSBUFSIZE = 2048 };
iov[j].siv_base = buf, iov[j].siv_len = m;
}
- nerror = ws_feed_buf(ws, buf, m);
+ nerror = ws_feed_buf(&wstp->ws, buf, m);
SU_DEBUG_9(("tport_ws_writevec: vec %p %p %lu ("MOD_ZD")\n",
- (void *)ws, (void *)iov[i].siv_base, (LU)iov[i].siv_len,
+ (void *)&wstp->ws, (void *)iov[i].siv_base, (LU)iov[i].siv_len,
nerror));
if (nerror == -1) {
break;
}
- ws_send_buf(ws, WSOC_TEXT);
+ ws_send_buf(&wstp->ws, WSOC_TEXT);
return size;
if ( wspri->ws_secure ) wstp->ws_secure = 1;
+
+ memset(&wstp->ws, 0, sizeof(wstp->ws));
+ if (ws_init(&wstp->ws, socket, 65336, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0) < 0) {
+ return *return_reason = "WS_INIT", -1;
+ }
+
+ wstp->ws_initialized = 1;
+ self->tp_pre_framed = 1;
+
return 0;
}
tport_ws_t *wstp = (tport_ws_t *)self;
if (wstp->ws_initialized == 1) {
- wsh_t *wsh = wstp->ws;
- SU_DEBUG_1(("%p destroy ws%s transport %p.\n", (void *) self, wstp->ws_secure ? "s" : "", (void *) wsh));
- ws_destroy(&wsh);
- wstp->ws_initialized = 1;
+ SU_DEBUG_1(("%p destroy ws%s transport %p.\n", (void *) self, wstp->ws_secure ? "s" : "", (void *) &wstp->ws));
+ ws_destroy(&wstp->ws);
+ wstp->ws_initialized = -1;
}
}