From a61f1bbd83f72b5c3d05cc2963440c4473f39c14 Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Thu, 22 Oct 2015 05:26:10 +0300 Subject: [PATCH] renaming; --- lib/sxmplv2.c | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/sxmplv2.c b/lib/sxmplv2.c index 1820023..88c27a7 100644 --- a/lib/sxmplv2.c +++ b/lib/sxmplv2.c @@ -42,13 +42,13 @@ #include #include -#include +#include #include "internal.h" typedef struct __sxmpl_bundle_type { void *buf; - conn_t *conn; + sxlink_t *conn; } sxmplv2_bundle_t; /* networking helpers */ @@ -73,7 +73,7 @@ int __resolvehost(const char *hostname, char *buf, int buf_len, } #endif -static int __conn_read(conn_t *co, void *buf, size_t buf_len) +static int __conn_read(sxlink_t *co, void *buf, size_t buf_len) { int rfd = SSL_get_fd(co->ssl), r; fd_set readset, writeset; @@ -169,7 +169,7 @@ static int __conn_read(conn_t *co, void *buf, size_t buf_len) return r; } -static int __conn_write(conn_t *co, void *buf, size_t buf_len) +static int __conn_write(sxlink_t *co, void *buf, size_t buf_len) { int r, rfd = SSL_get_fd(co->ssl); fd_set writeset; @@ -207,7 +207,7 @@ static int __conn_write(conn_t *co, void *buf, size_t buf_len) return r; } -int _sxmpl_writemsg(conn_t *co, sxmsg_t *msg) +int _sxmpl_writemsg(sxlink_t *co, sxmsg_t *msg) { sxmplv2_head_t *head; size_t rd; @@ -242,7 +242,7 @@ int _sxmpl_writemsg(conn_t *co, sxmsg_t *msg) return r; } -static sxmplv2_bundle_t *__sxmpl_bundle_create(conn_t *co) +static sxmplv2_bundle_t *__sxmpl_bundle_create(sxlink_t *co) { sxmplv2_bundle_t *n = malloc(sizeof(sxmplv2_bundle_t)); @@ -294,7 +294,7 @@ static int __verify_certcall(int preverify_ok, X509_STORE_CTX *ctx) // X509 *cert = X509_STORE_CTX_get_current_cert(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()); - conn_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; /* now we need to check for certificates with a long chain, @@ -398,13 +398,13 @@ void sxmp_finalize(void) return; } -conn_t *__connection_minimal_alloc(struct in_addr *addr) +sxlink_t *__link_minimal_alloc(struct in_addr *addr) { - conn_t *co = malloc(sizeof(conn_t)); + sxlink_t *co = malloc(sizeof(sxlink_t)); int r; if(!co) { r = ENOMEM; goto __fail; } - else memset(co, 0, sizeof(conn_t)); + else memset(co, 0, sizeof(sxlink_t)); if(!(co->messages = malloc(sizeof(uintptr_t)*1024))) { r = ENOMEM; goto __fail; } else memset(co->messages, 0, sizeof(uintptr_t)*1024); @@ -434,7 +434,7 @@ conn_t *__connection_minimal_alloc(struct in_addr *addr) return NULL; } -static int __connection_second_alloc(conn_t *co) +static int __link_second_alloc(sxlink_t *co) { usrtc_node_init(&co->csnode, co); @@ -464,7 +464,7 @@ static int __connection_second_alloc(conn_t *co) return SNE_ENOMEM; } -static void __connection_second_free(conn_t *co) +static void __link_second_free(sxlink_t *co) { if(co->channels) free(co->channels); idx_allocator_destroy(&co->idx_msg); @@ -479,7 +479,7 @@ static void __connection_second_free(conn_t *co) return; } -static void __connection_minimal_free(conn_t *co) +static void __link_minimal_free(sxlink_t *co) { if(co) { if(co->pctx) { @@ -494,7 +494,7 @@ static void __connection_minimal_free(conn_t *co) return; } -static int __eval_syssexp(conn_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; usrtc_node_t *node; @@ -520,19 +520,19 @@ static int __eval_syssexp(conn_t *co, sexp_t *sx) #define _CONN_NOTINUSE(co) (co)->usecount--; #define _CONN_UCOUNT(co) (co)->usecount #else -static inline void _CONN_INUSE(conn_t *co) { +static inline void _CONN_INUSE(sxlink_t *co) { pthread_rwlock_wrlock(&co->ssys->rwlock); co->usecount++; pthread_rwlock_unlock(&co->ssys->rwlock); } -static inline void _CONN_NOTINUSE(conn_t *co) { +static inline void _CONN_NOTINUSE(sxlink_t *co) { pthread_rwlock_wrlock(&co->ssys->rwlock); co->usecount--; pthread_rwlock_unlock(&co->ssys->rwlock); } -static inline int _CONN_UCOUNT(conn_t *co) { +static inline int _CONN_UCOUNT(sxlink_t *co) { int r; pthread_rwlock_rdlock(&co->ssys->rwlock); r = co->usecount; @@ -541,7 +541,7 @@ static inline int _CONN_UCOUNT(conn_t *co) { } #endif -static void __connection_destroy(conn_t *co) +static void __link_destroy(sxlink_t *co) { int i = 0, fd; sxmsg_t *msg, *omsg; @@ -627,8 +627,8 @@ static void __connection_destroy(conn_t *co) ERR_free_strings(); close(fd); - __connection_second_free(co); - __connection_minimal_free(co); + __link_second_free(co); + __link_minimal_free(co); } return; @@ -637,7 +637,7 @@ static void __connection_destroy(conn_t *co) static void *__sxmpl_thread(void *b) { sxmplv2_bundle_t *bun = (sxmplv2_bundle_t *)b; - conn_t *co = bun->conn; + sxlink_t *co = bun->conn; void *buf = bun->buf; char *bbuf = (char*)buf; sxmplv2_head_t *mhead = (sxmplv2_head_t *)buf; @@ -951,21 +951,22 @@ static void *__sxmpl_thread(void *b) __finish: co->flags |= SNSX_CLOSED; - __connection_destroy(co); + __link_destroy(co); __sxmpl_bundle_destroy(b); /* destroy bundle */ return NULL; } -conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) +sxlink_t *sxlink_master_accept(conn_sys_t *ssys, int sck, struct in_addr *addr) { void *buf = NULL; char *bbuf; - conn_t *co = __connection_minimal_alloc(addr); + sxlink_t *co = __link_minimal_alloc(addr); sxmsg_t *msg = NULL; sxmplv2_head_t *head; sxmplv2_bundle_t *bundle; + sexp_t *sx; size_t rd; - int r = SNE_FAILED; + int r = SNE_FAILED, i; if(!co) { errno = SNE_ENOMEM; @@ -1040,7 +1041,6 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) bbuf = (char *)buf; bbuf += sizeof(sxmplv2_head_t); - sexp_t *sx; while(co->flags & SNSX_BATCHMODE) { rd = __conn_read(co, buf, sizeof(sxmplv2_head_t)); if(rd == sizeof(sxmplv2_head_t)) { @@ -1090,7 +1090,7 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) } /* if we're there - negotiation is done, going to init messaging mode */ - r = __connection_second_alloc(co); + r = __link_second_alloc(co); if(r != SNE_SUCCESS) goto __fail3; /* free message */ @@ -1103,7 +1103,7 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) bundle->buf = buf; bundle->conn = co; } - int i; + for(i = 0; i < MAX_SNTLLTHREADS; i++) { if(bundle == (void *)0xdead) bundle = __sxmpl_bundle_create(co); if(!bundle) goto __fail5; @@ -1130,7 +1130,7 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) r = SNE_ENOMEM; /* bundles will be freed by the threads when SSL_read will fails. */ __fail4: - __connection_second_free(co); + __link_second_free(co); __fail3: if(ssys->on_destroy) ssys->on_destroy(co); __fail2: @@ -1143,10 +1143,10 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) ERR_remove_thread_state(0); ERR_remove_state(0); ERR_free_strings(); - + SSL_free(co->ssl); } - __connection_minimal_free(co); + __link_minimal_free(co); } close(sck); errno = r; @@ -1154,11 +1154,11 @@ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr) return NULL; } -conn_t *connection_link(conn_sys_t *ssys, const char *host, - int port, const char *SSL_cert, const char *login, - const char *passwd) +sxlink_t *sxlink_connect(conn_sys_t *ssys, const char *host, + int port, const char *SSL_cert, const char *login, + const char *passwd) { - conn_t *co = __connection_minimal_alloc(NULL); + sxlink_t *co = __link_minimal_alloc(NULL); struct hostent *host_; struct sockaddr_in addr; int r = SNE_SUCCESS, sck; @@ -1344,7 +1344,7 @@ conn_t *connection_link(conn_sys_t *ssys, const char *host, } /* if we're there - negotiation is done, going to init messaging mode */ - r = __connection_second_alloc(co); + r = __link_second_alloc(co); if(r != SNE_SUCCESS) goto __fail3; /* free message */ @@ -1377,7 +1377,7 @@ conn_t *connection_link(conn_sys_t *ssys, const char *host, r = SNE_ENOMEM; /* bundles will be freed by the threads when SSL_read will fails. */ __fail4: - __connection_second_free(co); + __link_second_free(co); __fail3: if(ssys->on_destroy) ssys->on_destroy(co); __fail2: @@ -1390,13 +1390,13 @@ conn_t *connection_link(conn_sys_t *ssys, const char *host, __fail: if(co) { if(co->ssl) SSL_free(co->ssl); - __connection_minimal_free(co); + __link_minimal_free(co); } errno = r; return NULL; } -int connection_close(conn_t *co) +int sxlink_close(sxlink_t *co) { sxmplv2_head_t mhead;