rename in library is done;

v0.5.xx
Alexander Vdolainen 9 years ago
parent de823c7063
commit 7657f6494a

@ -15,7 +15,7 @@ endif
SUBDIRS = include lib man $(EXAMPLES) $(TESTS) SUBDIRS = include lib man $(EXAMPLES) $(TESTS)
libsxmpdocdir = ${prefix}/doc/libsxmp libsxmpdocdir = ${prefix}/doc/libsxmp
libsntldoc_DATA = \ libsxmpdoc_DATA = \
README\ README\
COPYING\ COPYING\
AUTHORS\ AUTHORS\

@ -163,7 +163,7 @@ typedef struct __sxhub_type {
usrtc_t *links; usrtc_t *links;
pthread_rwlock_t rwlock; pthread_rwlock_t rwlock;
char *rootca, *certpem, *certkey; /* path name to the certificates */ char *rootca, *certpem, *certkey; /* path name to the certificates */
cx_rpc_list_t *system_rpc; sxl_rpclist_t *system_rpc;
/* special functions pointers */ /* special functions pointers */
int (*validate_sslpem)(sxlink_t *); /** < this function used to validate SSL certificate while SSL handshake */ int (*validate_sslpem)(sxlink_t *); /** < this function used to validate SSL certificate while SSL handshake */
int (*secure_check)(sxlink_t *); /** < this function authorize user to login, int (*secure_check)(sxlink_t *); /** < this function authorize user to login,
@ -189,7 +189,7 @@ typedef struct __sxhub_type {
typedef struct __rpc_typed_list_type { typedef struct __rpc_typed_list_type {
int type_id; int type_id;
char *description; char *description;
cx_rpc_list_t *rpc_list; sxl_rpclist_t *rpc_list;
usrtc_node_t lnode; usrtc_node_t lnode;
} rpc_typed_list_t; } rpc_typed_list_t;

@ -38,33 +38,33 @@
#include <tdata/usrtc.h> #include <tdata/usrtc.h>
#include <sexpr/sexp.h> #include <sexpr/sexp.h>
#include <sntl/sntllv2.h> #include <sxmp/sxmp.h>
#include "internal.h" #include "internal.h"
/* locally used functions */ /* locally used functions */
uint8_t _channel_open(conn_t *co, uint16_t *chid) uint8_t _channel_open(sxlink_t *co, uint16_t *chid)
{ {
chnl_t *chan; sxchnl_t *chan;
int typeid = *chid; /* our type */ int typeid = *chid; /* our type */
uint16_t chidx; uint16_t chidx;
usrtc_t *rpc_list = co->rpc_list; usrtc_t *rpc_list = co->rpc_list;
usrtc_node_t *node; usrtc_node_t *node;
rpc_typed_list_t *rlist; rpc_typed_list_t *rlist;
cx_rpc_list_t *rpclist; sxl_rpclist_t *rpclist;
node = usrtc_lookup(rpc_list, &typeid); node = usrtc_lookup(rpc_list, &typeid);
if(!node) return SNE_EPERM; if(!node) return SXE_EPERM;
else rlist = (rpc_typed_list_t *)usrtc_node_getdata(node); else rlist = (rpc_typed_list_t *)usrtc_node_getdata(node);
if(rlist) rpclist = rlist->rpc_list; if(rlist) rpclist = rlist->rpc_list;
else return SNE_FAILED; else return SXE_FAILED;
chan = malloc(sizeof(chnl_t)); chan = malloc(sizeof(sxchnl_t));
if(!chan) return SNE_ENOMEM; if(!chan) return SXE_ENOMEM;
/* init channel */ /* init channel */
chan->connection = co; chan->link = co;
chan->rpc_list = rpclist; chan->rpc_list = rpclist;
chan->flags = 0; chan->flags = 0;
@ -74,25 +74,25 @@ uint8_t _channel_open(conn_t *co, uint16_t *chid)
if(chidx == IDX_INVAL) { if(chidx == IDX_INVAL) {
free(chan); free(chan);
return SNE_MCHANNELS; return SXE_MCHANNELS;
} }
chan->cid = chidx; chan->cid = chidx;
co->channels[chidx] = chan; co->channels[chidx] = chan;
*chid = chidx; *chid = chidx;
return SNE_SUCCESS; return SXE_SUCCESS;
} }
uint8_t _channel_close(conn_t *co, uint16_t chid) uint8_t _channel_close(sxlink_t *co, uint16_t chid)
{ {
chnl_t *chan; sxchnl_t *chan;
ulong_t chidx = chid; ulong_t chidx = chid;
if(chid > 512) return SNE_INVALINDEX; if(chid > 512) return SXE_INVALINDEX;
else chan = co->channels[chidx]; else chan = co->channels[chidx];
if(!chan) return SNE_NOSUCHCHAN; if(!chan) return SXE_NOSUCHCHAN;
pthread_mutex_lock(&co->idx_ch_lock); pthread_mutex_lock(&co->idx_ch_lock);
idx_free(&co->idx_ch, chidx); idx_free(&co->idx_ch, chidx);
@ -101,31 +101,31 @@ uint8_t _channel_close(conn_t *co, uint16_t chid)
free(chan); free(chan);
return SNE_SUCCESS; return SXE_SUCCESS;
} }
chnl_t *sxchannel_open(conn_t *co, int type) sxchnl_t *sxchannel_open(sxlink_t *co, int type)
{ {
chnl_t *chan = NULL; sxchnl_t *chan = NULL;
sxmsg_t *msg = NULL; sxmsg_t *msg = NULL;
sntllv2_head_t *head; sxmplv2_head_t *head;
int msgidx, r, ccid; int msgidx, r, ccid;
if(!co) { if(!co) {
r = SNE_FAILED; r = SXE_FAILED;
goto __reterr; goto __reterr;
} }
if(!(chan = malloc(sizeof(chnl_t)))) { if(!(chan = malloc(sizeof(sxchnl_t)))) {
__enomem: __enomem:
if(chan) free(chan); if(chan) free(chan);
r = SNE_ENOMEM; r = SXE_ENOMEM;
goto __reterr; goto __reterr;
} }
if(!(msg = malloc(sizeof(sxmsg_t)))) goto __enomem; if(!(msg = malloc(sizeof(sxmsg_t)))) goto __enomem;
/* early init for the channel */ /* early init for the channel */
chan->connection = co; chan->link = co;
chan->flags = 0; chan->flags = 0;
/* early init for the message */ /* early init for the message */
@ -133,7 +133,7 @@ chnl_t *sxchannel_open(conn_t *co, int type)
pthread_mutex_lock(&msg->wait); pthread_mutex_lock(&msg->wait);
msg->pch = chan; msg->pch = chan;
msg->payload = NULL; msg->payload = NULL;
memset(&msg->mhead, 0, sizeof(sntllv2_head_t)); memset(&msg->mhead, 0, sizeof(sxmplv2_head_t));
head = &msg->mhead; head = &msg->mhead;
/* form a header */ /* form a header */
@ -147,16 +147,16 @@ chnl_t *sxchannel_open(conn_t *co, int type)
if(msgidx != IDX_INVAL) co->messages[msgidx] = msg; if(msgidx != IDX_INVAL) co->messages[msgidx] = msg;
pthread_mutex_unlock(&co->idx_msg_lock); pthread_mutex_unlock(&co->idx_msg_lock);
if(msgidx == IDX_INVAL) { r = SNE_MMESSAGES; goto __reterr2; } if(msgidx == IDX_INVAL) { r = SXE_MMESSAGES; goto __reterr2; }
else head->msgid = msgidx; else head->msgid = msgidx;
/* now we're ready to write it */ /* now we're ready to write it */
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
if(r == SNE_SUCCESS) pthread_mutex_lock(&msg->wait); if(r == SXE_SUCCESS) pthread_mutex_lock(&msg->wait);
else goto __reterr3; else goto __reterr3;
/* we will wakeup on return */ /* we will wakeup on return */
if(msg->mhead.opcode != SNE_SUCCESS) { r = msg->mhead.opcode; goto __reterr3; } if(msg->mhead.opcode != SXE_SUCCESS) { r = msg->mhead.opcode; goto __reterr3; }
/* ok all is fine */ /* ok all is fine */
chan->cid = msg->mhead.reserve; chan->cid = msg->mhead.reserve;
@ -194,24 +194,24 @@ chnl_t *sxchannel_open(conn_t *co, int type)
return NULL; return NULL;
} }
int sxchannel_close(chnl_t *channel) int sxchannel_close(sxchnl_t *channel)
{ {
int r = SNE_SUCCESS; int r = SXE_SUCCESS;
sxmsg_t *msg; sxmsg_t *msg;
sntllv2_head_t *head; sxmplv2_head_t *head;
conn_t *co; sxlink_t *co;
int msgidx = 0, chidx = 0; int msgidx = 0, chidx = 0;
/* check channel validity */ /* check channel validity */
if(!channel) return SNE_FAILED; if(!channel) return SXE_FAILED;
else if(!(co = channel->connection)) return SNE_FAILED; else if(!(co = channel->link)) return SXE_FAILED;
if(channel->cid > 512) return SNE_IGNORED; if(channel->cid > 512) return SXE_IGNORED;
else chidx = channel->cid; else chidx = channel->cid;
if(channel != co->channels[chidx]) return SNE_IGNORED; if(channel != co->channels[chidx]) return SXE_IGNORED;
if(!(msg = malloc(sizeof(sxmsg_t)))) return SNE_ENOMEM; if(!(msg = malloc(sizeof(sxmsg_t)))) return SXE_ENOMEM;
head = &msg->mhead; head = &msg->mhead;
memset(head, 0, sizeof(sntllv2_head_t)); memset(head, 0, sizeof(sxmplv2_head_t));
/* setup head */ /* setup head */
head->attr = SXMSG_PROTO | SXMSG_REPLYREQ; /* close channel */ head->attr = SXMSG_PROTO | SXMSG_REPLYREQ; /* close channel */
@ -228,11 +228,11 @@ int sxchannel_close(chnl_t *channel)
if(msgidx != IDX_INVAL) co->messages[msgidx] = msg; if(msgidx != IDX_INVAL) co->messages[msgidx] = msg;
pthread_mutex_unlock(&co->idx_msg_lock); pthread_mutex_unlock(&co->idx_msg_lock);
if(msgidx == IDX_INVAL) { r = SNE_MMESSAGES; goto __reterr2; } if(msgidx == IDX_INVAL) { r = SXE_MMESSAGES; goto __reterr2; }
else head->msgid = msgidx; else head->msgid = msgidx;
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
if(r == SNE_SUCCESS) { if(r == SXE_SUCCESS) {
pthread_mutex_lock(&msg->wait); pthread_mutex_lock(&msg->wait);
r = head->opcode; r = head->opcode;

@ -1,14 +1,14 @@
#ifndef __SNTLL_INTERNAL_H__ #ifndef __SXMPL_INTERNAL_H__
#define __SNTLL_INTERNAL_H__ #define __SXMPL_INTERNAL_H__
/* link related */ /* link related */
int _sntll_writemsg(conn_t *co, sxmsg_t *msg); int _sxmpl_writemsg(sxlink_t *co, sxmsg_t *msg);
/* channel operations */ /* channel operations */
uint8_t _channel_open(conn_t *co, uint16_t *chid); uint8_t _channel_open(sxlink_t *co, uint16_t *chid);
uint8_t _channel_close(conn_t *co, uint16_t chid); uint8_t _channel_close(sxlink_t *co, uint16_t chid);
/* messages */ /* messages */
void _message_process(sxmsg_t *msg); void _message_process(sxmsg_t *msg);
#endif /* __SNTLL_INTERNAL_H__ */ #endif /* __SXMPL_INTERNAL_H__ */

@ -38,11 +38,12 @@
#include <tdata/usrtc.h> #include <tdata/usrtc.h>
#include <sexpr/sexp.h> #include <sexpr/sexp.h>
#include <sntl/sntllv2.h> #include <sxmp/limits.h>
#include <sxmp/sxmp.h>
static int __insert_rpc_function(usrtc_t *tree, const char *name, int (*rpcf)(void *, sexp_t *)) static int __insert_rpc_function(usrtc_t *tree, const char *name, int (*rpcf)(void *, sexp_t *))
{ {
cx_rpc_t *ent = malloc(sizeof(cx_rpc_t)); sxl_rpc_t *ent = malloc(sizeof(sxl_rpc_t));
usrtc_node_t *node; usrtc_node_t *node;
if(!ent) return ENOMEM; if(!ent) return ENOMEM;
@ -62,10 +63,10 @@ static int __insert_rpc_function(usrtc_t *tree, const char *name, int (*rpcf)(vo
static void __destroy_rpc_list_tree(usrtc_t *tree) static void __destroy_rpc_list_tree(usrtc_t *tree)
{ {
usrtc_node_t *node; usrtc_node_t *node;
cx_rpc_t *ent; sxl_rpc_t *ent;
for(node = usrtc_first(tree); node != NULL; node = usrtc_first(tree)) { for(node = usrtc_first(tree); node != NULL; node = usrtc_first(tree)) {
ent = (cx_rpc_t *)usrtc_node_getdata(node); ent = (sxl_rpc_t *)usrtc_node_getdata(node);
usrtc_delete(tree, node); usrtc_delete(tree, node);
free(ent->name); free(ent->name);
free(ent); free(ent);
@ -83,45 +84,45 @@ static void __destroy_rpc_list_tree(usrtc_t *tree)
static int __set_credentials(void *cctx, sexp_t *sx) static int __set_credentials(void *cctx, sexp_t *sx)
{ {
register int idx; register int idx;
conn_t *co = (conn_t *)cctx; sxlink_t *co = (sxlink_t *)cctx;
conn_sys_t *ssys = co->ssys; sxhub_t *ssys = co->ssys;
sexp_t *isx; sexp_t *isx;
char *login = NULL; char *login = NULL;
char *passwd = NULL; char *passwd = NULL;
/* take a deal with S-exp */ /* take a deal with S-exp */
SEXP_ITERATE_LIST(sx, isx, idx) { SEXP_ITERATE_LIST(sx, isx, idx) {
if(isx->ty == SEXP_LIST) return SNE_BADPROTO; if(isx->ty == SEXP_LIST) return SXE_BADPROTO;
if(idx > 0 && isx->aty != SEXP_DQUOTE) return SNE_BADPROTO; if(idx > 0 && isx->aty != SEXP_DQUOTE) return SXE_BADPROTO;
if(idx == 1) login = isx->val; if(idx == 1) login = isx->val;
else if(idx == 2) passwd = isx->val; else if(idx == 2) passwd = isx->val;
else if(idx > 2) return SNE_BADPROTO; else if(idx > 2) return SXE_BADPROTO;
} }
if(!login || !passwd) return SNE_BADPROTO; if(!login || !passwd) return SXE_BADPROTO;
co->pctx->login = strdup(login); co->pctx->login = strdup(login);
co->pctx->passwd = strdup(passwd); co->pctx->passwd = strdup(passwd);
if(!co->pctx->login || !co->pctx->passwd) { if(!co->pctx->login || !co->pctx->passwd) {
if(co->pctx->login) free(co->pctx->login); if(co->pctx->login) free(co->pctx->login);
if(co->pctx->passwd) free(co->pctx->passwd); if(co->pctx->passwd) free(co->pctx->passwd);
return SNE_ENOMEM; return SXE_ENOMEM;
} }
if(ssys->secure_check) return ssys->secure_check(co); if(ssys->secure_check) return ssys->secure_check(co);
else return SNE_SUCCESS; else return SXE_SUCCESS;
} }
static int __get_channels_list(void *cctx, sexp_t *sx) static int __get_channels_list(void *cctx, sexp_t *sx)
{ {
conn_t *co = (conn_t *)cctx; sxlink_t *co = (sxlink_t *)cctx;
conn_sys_t *ssys = co->ssys; sxhub_t *ssys = co->ssys;
sxmsg_t *msg = co->messages[0]; sxmsg_t *msg = co->messages[0];
char *buf = msg->payload; char *buf = msg->payload;
usrtc_node_t *node; usrtc_node_t *node;
rpc_typed_list_t *list_ent; rpc_typed_list_t *list_ent;
size_t maxlen = 65535 - sizeof(sntllv2_head_t); size_t maxlen = 65535 - sizeof(sxmplv2_head_t);
size_t ulen = 0; size_t ulen = 0;
/* we will avoid S-exp scanning here */ /* we will avoid S-exp scanning here */
@ -129,8 +130,8 @@ static int __get_channels_list(void *cctx, sexp_t *sx)
/* call the function */ /* call the function */
if(ssys->get_rpc_typed_list_tree) if(ssys->get_rpc_typed_list_tree)
co->rpc_list = ssys->get_rpc_typed_list_tree(co); co->rpc_list = ssys->get_rpc_typed_list_tree(co);
if(!co->rpc_list) return SNE_EPERM; if(!co->rpc_list) return SXE_EPERM;
//buf += sizeof(sntllv2_head_t); //buf += sizeof(sxmplv2_head_t);
ulen += snprintf(buf + ulen, maxlen - ulen, "(set-channels-list "); ulen += snprintf(buf + ulen, maxlen - ulen, "(set-channels-list ");
for(node = usrtc_first(co->rpc_list); node != NULL; for(node = usrtc_first(co->rpc_list); node != NULL;
node = usrtc_next(co->rpc_list, node)) { /* fill the list */ node = usrtc_next(co->rpc_list, node)) { /* fill the list */
@ -142,49 +143,49 @@ static int __get_channels_list(void *cctx, sexp_t *sx)
msg->mhead.payload_length = ulen + 1; msg->mhead.payload_length = ulen + 1;
/* we're ready for messaging mode */ /* we're ready for messaging mode */
co->flags |= SNSX_MESSAGINGMODE; co->flags |= SXMP_MESSAGINGMODE;
return SNE_SUCCESS; return SXE_SUCCESS;
} }
static int __set_channels_list(void *cctx, sexp_t *sx) static int __set_channels_list(void *cctx, sexp_t *sx)
{ {
register int idx; register int idx;
conn_t *co = (conn_t *)cctx; sxlink_t *co = (sxlink_t *)cctx;
conn_sys_t *ssys = co->ssys; sxhub_t *ssys = co->ssys;
sexp_t *isx, *iisx; sexp_t *isx, *iisx;
int id, r; int id, r;
SEXP_ITERATE_LIST(sx, isx, idx) { SEXP_ITERATE_LIST(sx, isx, idx) {
if(!idx) continue; if(!idx) continue;
if(isx->ty != SEXP_LIST) return SNE_BADPROTO; if(isx->ty != SEXP_LIST) return SXE_BADPROTO;
if(sexp_list_length(isx) != 2) return SNE_BADPROTO; if(sexp_list_length(isx) != 2) return SXE_BADPROTO;
/* get id */ /* get id */
sexp_list_car(isx, &iisx); sexp_list_car(isx, &iisx);
if(iisx->ty == SEXP_LIST) return SNE_BADPROTO; if(iisx->ty == SEXP_LIST) return SXE_BADPROTO;
if(iisx->aty != SEXP_BASIC) return SNE_BADPROTO; if(iisx->aty != SEXP_BASIC) return SXE_BADPROTO;
if(iisx->val[0] != ':') return SNE_BADPROTO; if(iisx->val[0] != ':') return SXE_BADPROTO;
id = atoi(iisx->val + sizeof(char)); id = atoi(iisx->val + sizeof(char));
/* get short description */ /* get short description */
sexp_list_cdr(isx, &iisx); sexp_list_cdr(isx, &iisx);
if(iisx->ty == SEXP_LIST) return SNE_BADPROTO; if(iisx->ty == SEXP_LIST) return SXE_BADPROTO;
if(iisx->aty != SEXP_DQUOTE) return SNE_BADPROTO; if(iisx->aty != SEXP_DQUOTE) return SXE_BADPROTO;
/* ok, here we go */ /* ok, here we go */
if(ssys->set_typed_list_callback) { if(ssys->set_typed_list_callback) {
r = ssys->set_typed_list_callback(co, id, iisx->val); r = ssys->set_typed_list_callback(co, id, iisx->val);
if(r != SNE_SUCCESS) return r; if(r != SXE_SUCCESS) return r;
} }
} }
/* we're ready for messaging mode */ /* we're ready for messaging mode */
co->flags |= SNSX_MESSAGINGMODE; co->flags |= SXMP_MESSAGINGMODE;
co->flags &= ~SNSX_BATCHMODE; co->flags &= ~SXMP_BATCHMODE;
return SNE_SUCCESS; return SXE_SUCCESS;
} }
static int __init_systemrpc_tree(usrtc_t *rtree) static int __init_systemrpc_tree(usrtc_t *rtree)
@ -206,23 +207,23 @@ static long __cmp_cstr(const void *a, const void *b)
return (long)strcmp((const char *)a, (const char *)b); return (long)strcmp((const char *)a, (const char *)b);
} }
int connections_init(conn_sys_t *ssys) int links_init(sxhub_t *ssys)
{ {
int r = 0; int r = 0;
if(!ssys) return EINVAL; if(!ssys) return EINVAL;
else memset(ssys, 0, sizeof(conn_sys_t)); else memset(ssys, 0, sizeof(sxhub_t));
if(!(ssys->connections = malloc(sizeof(usrtc_t)))) return ENOMEM; if(!(ssys->links = malloc(sizeof(usrtc_t)))) return ENOMEM;
/* init connections list */ /* init links list */
usrtc_init(ssys->connections, USRTC_REDBLACK, MAX_CONNECTIONS, usrtc_init(ssys->links, USRTC_REDBLACK, MAX_LINKS,
__cmp_cstr); __cmp_cstr);
if((r = pthread_rwlock_init(&(ssys->rwlock), NULL))) if((r = pthread_rwlock_init(&(ssys->rwlock), NULL)))
goto __fini; goto __fini;
/* init RPC list related functions */ /* init RPC list related functions */
if(!(ssys->system_rpc = malloc(sizeof(cx_rpc_list_t)))) { if(!(ssys->system_rpc = malloc(sizeof(sxl_rpclist_t)))) {
r = ENOMEM; r = ENOMEM;
goto __lfini; goto __lfini;
} else { } else {
@ -244,42 +245,42 @@ int connections_init(conn_sys_t *ssys)
if(ssys->system_rpc) free(ssys->system_rpc); if(ssys->system_rpc) free(ssys->system_rpc);
pthread_rwlock_destroy(&(ssys->rwlock)); pthread_rwlock_destroy(&(ssys->rwlock));
__fini: __fini:
if(ssys->connections) free(ssys->connections); if(ssys->links) free(ssys->links);
return r; return r;
} }
int connections_free(conn_sys_t *ssys) int links_free(sxhub_t *ssys)
{ {
__destroy_rpc_list_tree(ssys->system_rpc->rpc_tree); __destroy_rpc_list_tree(ssys->system_rpc->rpc_tree);
free(ssys->system_rpc->rpc_tree); free(ssys->system_rpc->rpc_tree);
free(ssys->system_rpc); free(ssys->system_rpc);
free(ssys->connections); free(ssys->links);
pthread_rwlock_destroy(&(ssys->rwlock)); pthread_rwlock_destroy(&(ssys->rwlock));
SSL_CTX_free(ssys->ctx); SSL_CTX_free(ssys->ctx);
return 0; return 0;
} }
int connections_destroy(conn_sys_t *ssys) int links_destroy(sxhub_t *ssys)
{ {
int r = connections_free(ssys); int r = links_free(ssys);
free(ssys); free(ssys);
return r; return r;
} }
conn_sys_t *connections_create(void) sxhub_t *links_create(void)
{ {
int r = 0; int r = 0;
conn_sys_t *nsys = malloc(sizeof(conn_sys_t)); sxhub_t *nsys = malloc(sizeof(sxhub_t));
if(!nsys) { if(!nsys) {
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
r = connections_init(nsys); r = links_init(nsys);
if(r) { if(r) {
errno = r; errno = r;
free(nsys); free(nsys);
@ -289,7 +290,7 @@ conn_sys_t *connections_create(void)
return nsys; return nsys;
} }
int connections_setsslserts(conn_sys_t *ssys, const char *rootca, int links_setsslserts(sxhub_t *ssys, const char *rootca,
const char *certpem, const char *certkey) const char *certpem, const char *certkey)
{ {
int r = ENOMEM; int r = ENOMEM;
@ -316,31 +317,31 @@ struct __scerrcode {
}; };
static struct __scerrcode __lerr[] = { static struct __scerrcode __lerr[] = {
{SNE_SUCCESS, "Success"}, {SXE_SUCCESS, "Success"},
{SNE_FAILED, "Failed, invalid parameters given"}, {SXE_FAILED, "Failed, invalid parameters given"},
{SNE_ENOMEM, "Not enough memory"}, {SXE_ENOMEM, "Not enough memory"},
{SNE_BADPROTO, "Bad protocol"}, {SXE_BADPROTO, "Bad protocol"},
{SNE_ENORPC, "No such RPC exists"}, {SXE_ENORPC, "No such RPC exists"},
{SNE_EPERM, "Permission denied"}, {SXE_EPERM, "Permission denied"},
{SNE_TOOLONG, "Message data payload too long to be sent with one message pass"}, {SXE_TOOLONG, "Message data payload too long to be sent with one message pass"},
{SNE_EBUSY, "Index or working threads are busy"}, {SXE_EBUSY, "Index or working threads are busy"},
{SNE_WOULDBLOCK, "Call will block operation"}, {SXE_WOULDBLOCK, "Call will block operation"},
{SNE_LINKERROR, "Connection link error"}, {SXE_LINKERROR, "Connection link error"},
{SNE_NOSUCHMSG, "No such message"}, {SXE_NOSUCHMSG, "No such message"},
{SNE_NOSUCHCHAN, "No such channel"}, {SXE_NOSUCHCHAN, "No such channel"},
{SNE_ETIMEDOUT, "Timeout exceed"}, {SXE_ETIMEDOUT, "Timeout exceed"},
{SNE_IGNORED, "Function call was ignored"}, {SXE_IGNORED, "Function call was ignored"},
{SNE_REPLYREQ, "Reply required to the message"}, {SXE_REPLYREQ, "Reply required to the message"},
{SNE_RAPIDMSG, "Message is a rapid reply and dialog closed"}, {SXE_RAPIDMSG, "Message is a rapid reply and dialog closed"},
{SNE_ESSL, "SSL error occurs on connection link"}, {SXE_ESSL, "SSL error occurs on connection link"},
{SNE_NOCHANNELS, "No channels available"}, {SXE_NOCHANNELS, "No channels available"},
{SNE_MCHANNELS, "Active channels limit exceed"}, {SXE_MCHANNELS, "Active channels limit exceed"},
{SNE_MMESSAGES, "Active messages limit exceed"}, {SXE_MMESSAGES, "Active messages limit exceed"},
{SNE_LINKBROKEN, "Connection link was broken"}, {SXE_LINKBROKEN, "Connection link was broken"},
{SNE_INVALINDEX, "Invalid index given"}, {SXE_INVALINDEX, "Invalid index given"},
}; };
const char *sntll_errno2cstr(int ec) const char *sntll_errno2cstr(int ec)
{ {
return __lerr[ec - __SNTL_EPREFIX].desc; return __lerr[ec - __SXMP_EPREFIX].desc;
} }

@ -26,31 +26,31 @@
#include <tdata/list.h> #include <tdata/list.h>
#include <sexpr/sexp.h> #include <sexpr/sexp.h>
#include <sntl/limits.h> #include <sxmp/limits.h>
#include <sntl/sntllv2.h> #include <sxmp/sxmp.h>
#include "internal.h" #include "internal.h"
void _message_process(sxmsg_t *msg) void _message_process(sxmsg_t *msg)
{ {
chnl_t *chan = msg->pch; sxchnl_t *chan = msg->pch;
sexp_t *sx, *isx; sexp_t *sx, *isx;
usrtc_t *listrpc = chan->rpc_list->rpc_tree; usrtc_t *listrpc = chan->rpc_list->rpc_tree;
usrtc_node_t *node; usrtc_node_t *node;
cx_rpc_t *rpcc; sxl_rpc_t *rpcc;
int r; int r;
sx = parse_sexp(msg->payload, msg->mhead.payload_length); sx = parse_sexp(msg->payload, msg->mhead.payload_length);
if(!sx) sxmsg_return(msg, SNE_BADPROTO); if(!sx) sxmsg_return(msg, SXE_BADPROTO);
sexp_list_car(sx, &isx); sexp_list_car(sx, &isx);
if(!isx) { r = SNE_BADPROTO; goto __return_err; } if(!isx) { r = SXE_BADPROTO; goto __return_err; }
if(isx->ty == SEXP_LIST) { r = SNE_BADPROTO; goto __return_err; } if(isx->ty == SEXP_LIST) { r = SXE_BADPROTO; goto __return_err; }
if(isx->aty != SEXP_BASIC) { r = SNE_BADPROTO; goto __return_err; } if(isx->aty != SEXP_BASIC) { r = SXE_BADPROTO; goto __return_err; }
node = usrtc_lookup(listrpc, (void *)isx->val); node = usrtc_lookup(listrpc, (void *)isx->val);
if(!node) { r = SNE_ENORPC; goto __return_err; } if(!node) { r = SXE_ENORPC; goto __return_err; }
else rpcc = (cx_rpc_t *)usrtc_node_getdata(node); else rpcc = (sxl_rpc_t *)usrtc_node_getdata(node);
rpcc->rpcf((void *)msg, sx); rpcc->rpcf((void *)msg, sx);
@ -64,22 +64,22 @@ void _message_process(sxmsg_t *msg)
return; return;
} }
static inline int __sxmsg_send(chnl_t *channel, const char *data, size_t datalen, static inline int __sxmsg_send(sxchnl_t *channel, const char *data, size_t datalen,
sxmsg_t **omsg, int pp) sxmsg_t **omsg, int pp)
{ {
conn_t *co; sxlink_t *co;
sxmsg_t *msg; sxmsg_t *msg;
sntllv2_head_t *head; sxmplv2_head_t *head;
ppmsg_t *ppm; sxppmsg_t *ppm;
int msgidx, r; int msgidx, r;
if(!channel) return SNE_FAILED; if(!channel) return SXE_FAILED;
if(!data || !datalen) return SNE_FAILED; if(!data || !datalen) return SXE_FAILED;
if(!(msg = malloc(sizeof(sxmsg_t)))) return SNE_ENOMEM; if(!(msg = malloc(sizeof(sxmsg_t)))) return SXE_ENOMEM;
else memset(msg, 0, sizeof(sxmsg_t)); else memset(msg, 0, sizeof(sxmsg_t));
co = channel->connection; co = channel->link;
head = &msg->mhead; head = &msg->mhead;
/* form a head */ /* form a head */
head->attr = SXMSG_OPEN | SXMSG_REPLYREQ; head->attr = SXMSG_OPEN | SXMSG_REPLYREQ;
@ -96,13 +96,13 @@ static inline int __sxmsg_send(chnl_t *channel, const char *data, size_t datalen
if(msgidx != IDX_INVAL) co->messages[msgidx] = msg; if(msgidx != IDX_INVAL) co->messages[msgidx] = msg;
pthread_mutex_unlock(&co->idx_msg_lock); pthread_mutex_unlock(&co->idx_msg_lock);
if(msgidx == IDX_INVAL) { r = SNE_MMESSAGES; goto __freemsg; } if(msgidx == IDX_INVAL) { r = SXE_MMESSAGES; goto __freemsg; }
else head->msgid = (uint16_t)msgidx; else head->msgid = (uint16_t)msgidx;
/* ready to send it */ /* ready to send it */
if(!pp) { if(!pp) {
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
if(r != SNE_SUCCESS) { if(r != SXE_SUCCESS) {
__unpinmsg: __unpinmsg:
pthread_mutex_lock(&co->idx_msg_lock); pthread_mutex_lock(&co->idx_msg_lock);
idx_free(&co->idx_msg, msgidx); idx_free(&co->idx_msg, msgidx);
@ -111,7 +111,7 @@ static inline int __sxmsg_send(chnl_t *channel, const char *data, size_t datalen
goto __freemsg; goto __freemsg;
} }
} else { /* postponed */ } else { /* postponed */
if(!(ppm = malloc(sizeof(ppmsg_t)))) { r = SNE_ENOMEM; goto __unpinmsg; } if(!(ppm = malloc(sizeof(sxppmsg_t)))) { r = SXE_ENOMEM; goto __unpinmsg; }
list_init_node(&ppm->node); list_init_node(&ppm->node);
ppm->msg = msg; ppm->msg = msg;
@ -143,37 +143,37 @@ static inline int __sxmsg_send(chnl_t *channel, const char *data, size_t datalen
return r; return r;
} }
int sxmsg_send(chnl_t *channel, const char *data, size_t datalen, sxmsg_t **omsg) int sxmsg_send(sxchnl_t *channel, const char *data, size_t datalen, sxmsg_t **omsg)
{ {
return __sxmsg_send(channel, data, datalen, omsg, 0); return __sxmsg_send(channel, data, datalen, omsg, 0);
} }
/* the same - postponed message i.e. will be written to the queue - not to write immendatly */ /* the same - postponed message i.e. will be written to the queue - not to write immendatly */
int sxmsg_send_pp(chnl_t *channel, const char *data, size_t datalen, sxmsg_t **omsg) int sxmsg_send_pp(sxchnl_t *channel, const char *data, size_t datalen, sxmsg_t **omsg)
{ {
return __sxmsg_send(channel, data, datalen, omsg, 1); return __sxmsg_send(channel, data, datalen, omsg, 1);
} }
/* send a pulse message */ /* send a pulse message */
int sxmsg_pulse(conn_t *co, const char *data, size_t datalen) int sxmsg_pulse(sxlink_t *co, const char *data, size_t datalen)
{ {
sxmsg_t *msg = malloc(sizeof(sxmsg_t)); sxmsg_t *msg = malloc(sizeof(sxmsg_t));
sntllv2_head_t *head; sxmplv2_head_t *head;
int r; int r;
/* a little bit of paranoid tests */ /* a little bit of paranoid tests */
if(!msg) return SNE_ENOMEM; if(!msg) return SXE_ENOMEM;
else memset(msg, 0, sizeof(sxmsg_t)); else memset(msg, 0, sizeof(sxmsg_t));
/* prepare it */ /* prepare it */
head = &msg->mhead; head = &msg->mhead;
head->attr = 0; head->attr = 0;
head->attr = SXMSG_PULSE | SXMSG_LINK; head->attr = SXMSG_PULSE | SXMSG_LINK;
head->opcode = SNE_RAPIDMSG; head->opcode = SXE_RAPIDMSG;
head->payload_length = datalen; head->payload_length = datalen;
msg->payload = (void *)data; msg->payload = (void *)data;
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
free(msg); free(msg);
@ -183,35 +183,35 @@ int sxmsg_pulse(conn_t *co, const char *data, size_t datalen)
static inline int __sxmsg_reply(sxmsg_t *msg, const char *data, static inline int __sxmsg_reply(sxmsg_t *msg, const char *data,
size_t datalen, int pp) size_t datalen, int pp)
{ {
chnl_t *ch; sxchnl_t *ch;
conn_t *co; sxlink_t *co;
sntllv2_head_t *head; sxmplv2_head_t *head;
ppmsg_t *ppm; sxppmsg_t *ppm;
int r, i; int r, i;
pthread_t self = pthread_self(); pthread_t self = pthread_self();
/* a little bit of paranoid tests */ /* a little bit of paranoid tests */
if(!msg) return SNE_FAILED; if(!msg) return SXE_FAILED;
if(!(ch = msg->pch)) return SNE_FAILED; if(!(ch = msg->pch)) return SXE_FAILED;
if(!(co = ch->connection)) return SNE_FAILED; if(!(co = ch->link)) return SXE_FAILED;
/* test for blocking */ /* test for blocking */
for(i = 0; i < MAX_SNTLLTHREADS; i++) for(i = 0; i < MAX_SXMPLTHREADS; i++)
if(pthread_equal(self, co->thrd_poll[i])) return SNE_WOULDBLOCK; if(pthread_equal(self, co->thrd_poll[i])) return SXE_WOULDBLOCK;
/* prepare it */ /* prepare it */
head = &msg->mhead; head = &msg->mhead;
head->attr = 0; head->attr = 0;
head->attr |= SXMSG_REPLYREQ; head->attr |= SXMSG_REPLYREQ;
head->opcode = SNE_REPLYREQ; head->opcode = SXE_REPLYREQ;
head->payload_length = datalen; head->payload_length = datalen;
msg->payload = (void *)data; msg->payload = (void *)data;
if(!pp) { if(!pp) {
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
if(r != SNE_SUCCESS) return r; if(r != SXE_SUCCESS) return r;
} else { } else {
if(!(ppm = malloc(sizeof(ppmsg_t)))) return SNE_ENOMEM; if(!(ppm = malloc(sizeof(sxppmsg_t)))) return SXE_ENOMEM;
list_init_node(&ppm->node); list_init_node(&ppm->node);
ppm->msg = msg; ppm->msg = msg;
@ -247,21 +247,21 @@ int sxmsg_reply_pp(sxmsg_t *msg, const char *data, size_t datalen)
int sxmsg_rreply(sxmsg_t *msg, size_t datalen) int sxmsg_rreply(sxmsg_t *msg, size_t datalen)
{ {
chnl_t *ch; sxchnl_t *ch;
conn_t *co; sxlink_t *co;
sntllv2_head_t *head; sxmplv2_head_t *head;
int r, mid; int r, mid;
/* a little bit of paranoid tests */ /* a little bit of paranoid tests */
if(!msg) return SNE_FAILED; if(!msg) return SXE_FAILED;
if(!(ch = msg->pch)) return SNE_FAILED; if(!(ch = msg->pch)) return SXE_FAILED;
if(!(co = ch->connection)) return SNE_FAILED; if(!(co = ch->link)) return SXE_FAILED;
/* prepare it */ /* prepare it */
head = &msg->mhead; head = &msg->mhead;
head->attr = 0; head->attr = 0;
head->attr |= SXMSG_CLOSED; head->attr |= SXMSG_CLOSED;
head->opcode = SNE_RAPIDMSG; head->opcode = SXE_RAPIDMSG;
head->payload_length = datalen; head->payload_length = datalen;
mid = head->msgid; mid = head->msgid;
@ -270,7 +270,7 @@ int sxmsg_rreply(sxmsg_t *msg, size_t datalen)
co->messages[mid] = NULL; co->messages[mid] = NULL;
pthread_mutex_unlock(&co->idx_msg_lock); pthread_mutex_unlock(&co->idx_msg_lock);
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
pthread_mutex_unlock(&msg->wait); /* we able to invalidate it */ pthread_mutex_unlock(&msg->wait); /* we able to invalidate it */
pthread_mutex_destroy(&msg->wait); pthread_mutex_destroy(&msg->wait);
@ -281,16 +281,16 @@ int sxmsg_rreply(sxmsg_t *msg, size_t datalen)
static inline int __sxmsg_return(sxmsg_t *msg, int opcode, int pp) static inline int __sxmsg_return(sxmsg_t *msg, int opcode, int pp)
{ {
chnl_t *ch; sxchnl_t *ch;
conn_t *co; sxlink_t *co;
sntllv2_head_t *head; sxmplv2_head_t *head;
ppmsg_t *ppm; sxppmsg_t *ppm;
int r, mid; int r, mid;
/* a little bit of paranoid tests */ /* a little bit of paranoid tests */
if(!msg) return SNE_FAILED; if(!msg) return SXE_FAILED;
if(!(ch = msg->pch)) return SNE_FAILED; if(!(ch = msg->pch)) return SXE_FAILED;
if(!(co = ch->connection)) return SNE_FAILED; if(!(co = ch->link)) return SXE_FAILED;
head = &msg->mhead; head = &msg->mhead;
head->attr = 0; head->attr = 0;
@ -306,10 +306,10 @@ static inline int __sxmsg_return(sxmsg_t *msg, int opcode, int pp)
co->messages[mid] = NULL; co->messages[mid] = NULL;
pthread_mutex_unlock(&co->idx_msg_lock); pthread_mutex_unlock(&co->idx_msg_lock);
r = _sntll_writemsg(co, msg); r = _sxmpl_writemsg(co, msg);
free(msg); free(msg);
} else { } else {
if(!(ppm = malloc(sizeof(ppmsg_t)))) return SNE_ENOMEM; if(!(ppm = malloc(sizeof(sxppmsg_t)))) return SXE_ENOMEM;
else { /* remove it */ else { /* remove it */
pthread_mutex_lock(&co->idx_msg_lock); pthread_mutex_lock(&co->idx_msg_lock);
idx_free(&co->idx_msg, mid); idx_free(&co->idx_msg, mid);
@ -326,7 +326,7 @@ static inline int __sxmsg_return(sxmsg_t *msg, int opcode, int pp)
list_add2tail(&co->write_pending, &ppm->node); /* push it to the FIFO */ list_add2tail(&co->write_pending, &ppm->node); /* push it to the FIFO */
pthread_mutex_unlock(&co->write_pending_lock); pthread_mutex_unlock(&co->write_pending_lock);
r = SNE_SUCCESS; r = SXE_SUCCESS;
} }
return r; return r;

@ -16,8 +16,8 @@
#include <tdata/usrtc.h> #include <tdata/usrtc.h>
#include <sexpr/sexp.h> #include <sexpr/sexp.h>
#include <sntl/sntllv2.h> #include <sxmp/sxmp.h>
#include <sntl/limits.h> #include <sxmp/limits.h>
static long __cmp_int(const void *a, const void *b) static long __cmp_int(const void *a, const void *b)
{ {
@ -39,7 +39,7 @@ int sntl_rpclist_add(usrtc_t *tree, int type, const char *description,
const char *version) const char *version)
{ {
rpc_typed_list_t *nlist = NULL; rpc_typed_list_t *nlist = NULL;
cx_rpc_list_t *rpc_list = NULL; sxl_rpclist_t *rpc_list = NULL;
usrtc_t *rtree = NULL; usrtc_t *rtree = NULL;
usrtc_node_t *node = NULL; usrtc_node_t *node = NULL;
int r = ENOMEM; int r = ENOMEM;
@ -51,8 +51,8 @@ int sntl_rpclist_add(usrtc_t *tree, int type, const char *description,
/* allocate all */ /* allocate all */
if(!(nlist = malloc(sizeof(rpc_typed_list_t)))) goto __fail; if(!(nlist = malloc(sizeof(rpc_typed_list_t)))) goto __fail;
else memset(nlist, 0, sizeof(rpc_typed_list_t)); else memset(nlist, 0, sizeof(rpc_typed_list_t));
if(!(rpc_list = malloc(sizeof(cx_rpc_list_t)))) goto __fail; if(!(rpc_list = malloc(sizeof(sxl_rpclist_t)))) goto __fail;
else memset(rpc_list, 0, sizeof(cx_rpc_list_t)); else memset(rpc_list, 0, sizeof(sxl_rpclist_t));
if(!(rtree = malloc(sizeof(usrtc_t)))) goto __fail; if(!(rtree = malloc(sizeof(usrtc_t)))) goto __fail;
/* version and description */ /* version and description */
@ -86,8 +86,8 @@ int sntl_rpclist_add_function(usrtc_t *tree, int type, const char *fu_name,
{ {
usrtc_node_t *node; usrtc_node_t *node;
rpc_typed_list_t *tlist; rpc_typed_list_t *tlist;
cx_rpc_list_t *rlist; sxl_rpclist_t *rlist;
cx_rpc_t *rentry = NULL; sxl_rpc_t *rentry = NULL;
node = usrtc_lookup(tree, &type); node = usrtc_lookup(tree, &type);
if(!node) return ENOENT; if(!node) return ENOENT;
@ -97,7 +97,7 @@ int sntl_rpclist_add_function(usrtc_t *tree, int type, const char *fu_name,
/* ok, we don't allow dupes */ /* ok, we don't allow dupes */
node = usrtc_lookup(rlist->rpc_tree, fu_name); node = usrtc_lookup(rlist->rpc_tree, fu_name);
if(node) return EEXIST; if(node) return EEXIST;
if(!(rentry = malloc(sizeof(cx_rpc_t)))) return ENOMEM; if(!(rentry = malloc(sizeof(sxl_rpc_t)))) return ENOMEM;
else if(!(rentry->name = strdup(fu_name))) { else if(!(rentry->name = strdup(fu_name))) {
free(rentry); free(rentry);
return ENOMEM; return ENOMEM;
@ -124,11 +124,11 @@ int sntl_rpclist_filter(usrtc_t *source, usrtc_t **dest, int flag, int *filter)
else usrtc_init(destination, USRTC_REDBLACK, MAX_RPC_LIST, __cmp_int); else usrtc_init(destination, USRTC_REDBLACK, MAX_RPC_LIST, __cmp_int);
switch(flag) { switch(flag) {
case SNTL_FILTER_EXC: case SXMP_FILTER_EXC:
for(node = usrtc_first(source); ; node = usrtc_next(source, node)) { for(node = usrtc_first(source); ; node = usrtc_next(source, node)) {
tlist = (rpc_typed_list_t *)usrtc_node_getdata(node); tlist = (rpc_typed_list_t *)usrtc_node_getdata(node);
r = ENOENT; r = ENOENT;
for(i = *f; i != SNTL_FILTER_END; f++, i = *f) { for(i = *f; i != SXMP_FILTER_END; f++, i = *f) {
if(tlist->type_id == i) { if(tlist->type_id == i) {
r = 0; break; r = 0; break;
} }
@ -148,8 +148,8 @@ int sntl_rpclist_filter(usrtc_t *source, usrtc_t **dest, int flag, int *filter)
} }
r = 0; r = 0;
break; break;
case SNTL_FILTER_INC: case SXMP_FILTER_INC:
for(i = *f; i != SNTL_FILTER_END; f++, i = *f) { for(i = *f; i != SXMP_FILTER_END; f++, i = *f) {
node = usrtc_lookup(source, &i); node = usrtc_lookup(source, &i);
if(!node) continue; /* skip it at all */ if(!node) continue; /* skip it at all */
else tlist = (rpc_typed_list_t *)usrtc_node_getdata(node); else tlist = (rpc_typed_list_t *)usrtc_node_getdata(node);

@ -294,7 +294,7 @@ static int __verify_certcall(int preverify_ok, X509_STORE_CTX *ctx)
int err = X509_STORE_CTX_get_error(ctx), depth = X509_STORE_CTX_get_error_depth(ctx); int err = X509_STORE_CTX_get_error(ctx), depth = X509_STORE_CTX_get_error_depth(ctx);
SSL *ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); SSL *ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
sxlink_t *co = SSL_get_ex_data(ssl, ex_ssldata_index); /* this is a custom data we're set before */ sxlink_t *co = SSL_get_ex_data(ssl, ex_ssldata_index); /* this is a custom data we're set before */
conn_sys_t *ssys = co->ssys; sxhub_t *ssys = co->ssys;
/* now we need to check for certificates with a long chain, /* now we need to check for certificates with a long chain,
* so since we have a short one, reject long ones */ * so since we have a short one, reject long ones */
@ -408,8 +408,8 @@ sxlink_t *__link_minimal_alloc(struct in_addr *addr)
if(!(co->messages = malloc(sizeof(uintptr_t)*1024))) { r = ENOMEM; goto __fail; } if(!(co->messages = malloc(sizeof(uintptr_t)*1024))) { r = ENOMEM; goto __fail; }
else memset(co->messages, 0, sizeof(uintptr_t)*1024); else memset(co->messages, 0, sizeof(uintptr_t)*1024);
if(!(co->pctx = malloc(sizeof(perm_ctx_t)))) { r = ENOMEM; goto __fail; } if(!(co->pctx = malloc(sizeof(sxsession_ctx_t)))) { r = ENOMEM; goto __fail; }
else memset(co->pctx, 0, sizeof(perm_ctx_t)); else memset(co->pctx, 0, sizeof(sxsession_ctx_t));
if(addr) { if(addr) {
if(!(co->pctx->addr = malloc(sizeof(struct in_addr)))) { r = ENOMEM; goto __fail; } if(!(co->pctx->addr = malloc(sizeof(struct in_addr)))) { r = ENOMEM; goto __fail; }
@ -495,9 +495,9 @@ static void __link_minimal_free(sxlink_t *co)
static int __eval_syssexp(sxlink_t *co, sexp_t *sx) static int __eval_syssexp(sxlink_t *co, sexp_t *sx)
{ {
cx_rpc_list_t *rpc_list = co->ssys->system_rpc; sxl_rpclist_t *rpc_list = co->ssys->system_rpc;
usrtc_node_t *node; usrtc_node_t *node;
cx_rpc_t *rentry; sxl_rpc_t *rentry;
char *rpcf; char *rpcf;
if(sx->ty == SEXP_LIST) if(sx->ty == SEXP_LIST)
@ -508,13 +508,13 @@ static int __eval_syssexp(sxlink_t *co, sexp_t *sx)
node = usrtc_lookup(rpc_list->rpc_tree, rpcf); node = usrtc_lookup(rpc_list->rpc_tree, rpcf);
if(!node) return SXE_ENORPC; if(!node) return SXE_ENORPC;
else rentry = (cx_rpc_t *)usrtc_node_getdata(node); else rentry = (sxl_rpc_t *)usrtc_node_getdata(node);
/* call it */ /* call it */
return rentry->rpcf((void *)co, sx); return rentry->rpcf((void *)co, sx);
} }
#ifdef _NO_SNTLMP #ifdef _NO_SXMPMP
#define _CONN_INUSE(co) (co)->usecount++; #define _CONN_INUSE(co) (co)->usecount++;
#define _CONN_NOTINUSE(co) (co)->usecount--; #define _CONN_NOTINUSE(co) (co)->usecount--;
#define _CONN_UCOUNT(co) (co)->usecount #define _CONN_UCOUNT(co) (co)->usecount
@ -544,17 +544,17 @@ static void __link_destroy(sxlink_t *co)
{ {
int i = 0, fd; int i = 0, fd;
sxmsg_t *msg, *omsg; sxmsg_t *msg, *omsg;
ppmsg_t *ppm; sxppmsg_t *ppm;
list_node_t *iter, *siter; list_node_t *iter, *siter;
chnl_t *chan; sxchnl_t *chan;
sxmplv2_head_t *head; sxmplv2_head_t *head;
conn_sys_t *ssys = co->ssys; sxhub_t *ssys = co->ssys;
/* first we will unpin all messages and mark it as errors on */ /* first we will unpin all messages and mark it as errors on */
if(co->pending_messages) { if(co->pending_messages) {
pthread_mutex_lock(&co->write_pending_lock); pthread_mutex_lock(&co->write_pending_lock);
list_for_each_safe(&co->write_pending, iter, siter) { list_for_each_safe(&co->write_pending, iter, siter) {
ppm = container_of(iter, ppmsg_t, node); ppm = container_of(iter, sxppmsg_t, node);
omsg = ppm->msg; omsg = ppm->msg;
/* ok, now we're able to remove it from list */ /* ok, now we're able to remove it from list */
@ -642,9 +642,9 @@ static void *__sxmpl_thread(void *b)
sxmplv2_head_t *mhead = (sxmplv2_head_t *)buf; sxmplv2_head_t *mhead = (sxmplv2_head_t *)buf;
sxmsg_t *msg, *omsg; sxmsg_t *msg, *omsg;
sexp_t *sx; sexp_t *sx;
chnl_t *channel; sxchnl_t *channel;
list_node_t *iter, *siter; list_node_t *iter, *siter;
ppmsg_t *ppm; sxppmsg_t *ppm;
pthread_t self = pthread_self(); pthread_t self = pthread_self();
struct timespec wtick; struct timespec wtick;
int dispatch = 0, e; int dispatch = 0, e;
@ -684,7 +684,7 @@ static void *__sxmpl_thread(void *b)
if(co->pending_messages && !(co->flags & SXMP_CLOSED)) { if(co->pending_messages && !(co->flags & SXMP_CLOSED)) {
pthread_mutex_lock(&co->write_pending_lock); pthread_mutex_lock(&co->write_pending_lock);
list_for_each_safe(&co->write_pending, iter, siter) { list_for_each_safe(&co->write_pending, iter, siter) {
ppm = container_of(iter, ppmsg_t, node); ppm = container_of(iter, sxppmsg_t, node);
omsg = ppm->msg; omsg = ppm->msg;
if(_sxmpl_writemsg(co, omsg) != SXE_SUCCESS) { if(_sxmpl_writemsg(co, omsg) != SXE_SUCCESS) {
pthread_mutex_unlock(&co->write_pending_lock); pthread_mutex_unlock(&co->write_pending_lock);
@ -955,7 +955,7 @@ static void *__sxmpl_thread(void *b)
return NULL; return NULL;
} }
sxlink_t *sxlink_master_accept(conn_sys_t *ssys, int sck, struct in_addr *addr) sxlink_t *sxlink_master_accept(sxhub_t *ssys, int sck, struct in_addr *addr)
{ {
void *buf = NULL; void *buf = NULL;
char *bbuf; char *bbuf;
@ -1103,7 +1103,7 @@ sxlink_t *sxlink_master_accept(conn_sys_t *ssys, int sck, struct in_addr *addr)
bundle->conn = co; bundle->conn = co;
} }
for(i = 0; i < MAX_SNTLLTHREADS; i++) { for(i = 0; i < MAX_SXMPLTHREADS; i++) {
if(bundle == (void *)0xdead) bundle = __sxmpl_bundle_create(co); if(bundle == (void *)0xdead) bundle = __sxmpl_bundle_create(co);
if(!bundle) goto __fail5; if(!bundle) goto __fail5;
r = pthread_create(&co->thrd_poll[i], NULL, __sxmpl_thread, bundle); /* and here, alloc tls */ r = pthread_create(&co->thrd_poll[i], NULL, __sxmpl_thread, bundle); /* and here, alloc tls */
@ -1153,7 +1153,7 @@ sxlink_t *sxlink_master_accept(conn_sys_t *ssys, int sck, struct in_addr *addr)
return NULL; return NULL;
} }
sxlink_t *sxlink_connect(conn_sys_t *ssys, const char *host, sxlink_t *sxlink_connect(sxhub_t *ssys, const char *host,
int port, const char *SSL_cert, const char *login, int port, const char *SSL_cert, const char *login,
const char *passwd) const char *passwd)
{ {
@ -1356,7 +1356,7 @@ sxlink_t *sxlink_connect(conn_sys_t *ssys, const char *host,
bundle->buf = buf; bundle->buf = buf;
bundle->conn = co; bundle->conn = co;
} }
for(i = 0; i < MAX_SNTLLTHREADS; i++) { for(i = 0; i < MAX_SXMPLTHREADS; i++) {
if(bundle == (void *)0xdead) bundle = __sxmpl_bundle_create(co); if(bundle == (void *)0xdead) bundle = __sxmpl_bundle_create(co);
if(!bundle) goto __fail5; if(!bundle) goto __fail5;
r = pthread_create(&co->thrd_poll[i], NULL, __sxmpl_thread, bundle); r = pthread_create(&co->thrd_poll[i], NULL, __sxmpl_thread, bundle);

@ -15,18 +15,14 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef WIN32 #ifdef WIN32
#include <Winsock2.h> #include <Winsock2.h>
#include <windows.h> #include <windows.h>
#include <rpc.h> #include <rpc.h>
#else #else
#include <sys/select.h> #include <sys/select.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>

Loading…
Cancel
Save