stay tuned folksgit add lib/sntllv2.c lib/connex.c;

v0.5.xx
Alexander Vdolainen 9 years ago
parent b09d7d6a10
commit 569176169f

@ -137,6 +137,9 @@ static int __get_channels_list(void *cctx, sexp_t *sx)
ulen += snprintf(buf + ulen, maxlen - ulen, ")");
msg->payload_length = ulen + sizeof(sntllv2_head_t);
/* we're ready for messaging mode */
co->flags |= SNSX_MESSAGINGMODE;
return SNE_SUCCESS;
}
@ -173,6 +176,9 @@ static int __set_channels_list(void *cctx, sexp_t *sx)
}
}
/* we're ready for messaging mode */
co->flags |= SNSX_MESSAGINGMODE;
return SNE_SUCCESS;
}

@ -165,6 +165,27 @@ static void __connection_minimal_free(conn_t *co)
return;
}
static int __eval_syssexp(conn_t *co, sexp_t *sx)
{
cx_rpc_list_t *rpc_list = co->ssys->system_rpc;
usrtc_node_t *node;
cx_rpc_t *rentry;
char *rpcf;
if(sx->ty == SEXP_LIST)
rpcf = sx->list->val;
else return SNE_BADPROTO;
/* find an appropriate function */
node = usrtc_lookup(rpc_list->rpc_tree, rpcf);
if(!node) return SNE_ENORPC;
else rentry = (cx_rpc_t *)usrtc_node_getdata(node);
/* call it */
return rentry->rpcf((void *)co, sx);
}
int connection_create_fapi_m(conn_sys_t *ssys, conn_t *co, int sck,
struct in_addr *addr)
{
@ -218,9 +239,7 @@ int connection_create_fapi_m(conn_sys_t *ssys, conn_t *co, int sck,
/* set the context to verify ssl connection */
SSL_set_ex_data(co->ssl, ex_ssldata_index, (void *)co);
SSL_set_accept_state(co->ssl);
if(SSL_accept(co->ssl) == -1) {
goto __fail;
}
if(SSL_accept(co->ssl) == -1) goto __fail;
/* ok, now we are able to allocate and so on */
/* set connection to the batch mode */
@ -245,6 +264,12 @@ int connection_create_fapi_m(conn_sys_t *ssys, conn_t *co, int sck,
/* check for returns */
if(head->opcode != SNE_SUCCESS) goto __fail3;
else { /* opcode is fine */
/* if we're ready for messaging mode, turn off batch mode */
if(co->flags & SNSX_MESSAGINGMODE) co->flags &= ~SNSX_BATCHMODE;
}
if(!head->payload_length) continue; /* pass the following check up */
rd = __conn_read(co, bbuf, head->payload_length);
if(rd != head->payload_length) goto __fail3;
@ -257,10 +282,16 @@ int connection_create_fapi_m(conn_sys_t *ssys, conn_t *co, int sck,
msg->payload_length = 0;
/* deal with it */
r = __eval_syssexp(co, sx);
if(r != SNE_SUCCESS) { /* fuck */
head->opcode = r;
head->opcode = r;
if(r != SNE_SUCCESS) { /* we finish */
head->payload_length = 0;
__conn_write(co, buf, sizeof(sntllv2_head_t));
destroy_sexp(sx);
goto __fail3;
}
rd = __conn_write(co, buf, sizeof(sntllv2_head_t) + msg->payload_length);
if(rd != sizeof(sntllv2_head_t) + msg->payload_length) {
destroy_sexp(sx);
goto __fail3;
}
@ -268,8 +299,16 @@ int connection_create_fapi_m(conn_sys_t *ssys, conn_t *co, int sck,
} else goto __fail3;
}
/* if we're there - negotiation is done, going to init messaging mode */
r = __connection_second_alloc(co);
if(r != SNE_SUCCESS) goto __fail3;
/* and now we're need to create a thread poll */
return SNE_SUCCESS;
__fail4:
__connection_second_free(co);
__fail3:
if(ssys->on_destroy) ssys->on_destroy(co);
__fail2:

Loading…
Cancel
Save