version 1.6.2.1, 2012/03/12 16:28:09
|
version 1.6.2.2, 2012/03/13 17:10:13
|
Line 99 calcHashes(rpc_func_t * __restrict func, const char *c
|
Line 99 calcHashes(rpc_func_t * __restrict func, const char *c
|
assert(func && csFunc); |
assert(func && csFunc); |
|
|
/* set function name */ |
/* set function name */ |
func->func_name = (u_char*) csFunc; | AIT_SET_STR(&func->func_name, csFunc); |
len = strlen(csFunc) + 3; /* extra 3 bytes, because add string "__" and 0 */ |
len = strlen(csFunc) + 3; /* extra 3 bytes, because add string "__" and 0 */ |
/* set module name if exists */ |
/* set module name if exists */ |
if (csModule) { |
if (csModule) { |
func->func_file = (u_char*) csModule; | AIT_SET_STR(&func->func_file, csModule); |
len += strlen(csModule); |
len += strlen(csModule); |
} |
} |
/* align len to 2 */ |
/* align len to 2 */ |
Line 116 calcHashes(rpc_func_t * __restrict func, const char *c
|
Line 116 calcHashes(rpc_func_t * __restrict func, const char *c
|
return -1; |
return -1; |
} else { |
} else { |
memset(str, 0, len); |
memset(str, 0, len); |
if (func->func_file) | if (csModule) |
strlcpy((char*) str, csModule, len); |
strlcpy((char*) str, csModule, len); |
strlcat((char*) str, "__", len); |
strlcat((char*) str, "__", len); |
strlcat((char*) str, csFunc, len); |
strlcat((char*) str, csFunc, len); |
Line 156 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
Line 156 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
} else |
} else |
memset(func, 0, sizeof(rpc_func_t)); |
memset(func, 0, sizeof(rpc_func_t)); |
|
|
/* set function name */ |
|
func->func_name = strdup(csFunc); |
|
/* set module name if exists */ |
|
if (csModule) |
|
func->func_file = strdup(csModule); |
|
|
|
/* calculate hashes */ |
/* calculate hashes */ |
if (calcHashes(func, func->func_file, func->func_name) == -1) { | if (calcHashes(func, csModule, csFunc) == -1) { |
free(func->func_name); | AIT_FREE_VAL(&func->func_name); |
if (func->func_file) | AIT_FREE_VAL(&func->func_file); |
free(func->func_file); | |
free(func); |
free(func); |
return -1; |
return -1; |
} |
} |
Line 175 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
Line 168 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
|
|
/* allocate return variables */ |
/* allocate return variables */ |
if (args > 0 && rpc_srv_allocVars(func, args) == -1) { |
if (args > 0 && rpc_srv_allocVars(func, args) == -1) { |
free(func->func_name); | AIT_FREE_VAL(&func->func_name); |
if (func->func_file) | AIT_FREE_VAL(&func->func_file); |
free(func->func_file); | |
free(func); |
free(func); |
return -1; |
return -1; |
} |
} |
Line 213 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
Line 205 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
if (calcHashes(&func, csModule, csFunc) == -1) |
if (calcHashes(&func, csModule, csFunc) == -1) |
return -1; |
return -1; |
|
|
pthread_mutex_lock(&srv->srv_mtx); |
|
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
|
AIT_FREE_VAL(&func.func_name); |
|
AIT_FREE_VAL(&func.func_file); |
if (!f) /* not found element for unregister */ |
if (!f) /* not found element for unregister */ |
return 0; |
return 0; |
|
|
|
pthread_mutex_lock(&srv->srv_mtx); |
/* remove from list of functions */ |
/* remove from list of functions */ |
if (srv->srv_funcs == f) /* if is 1st element */ |
if (srv->srv_funcs == f) /* if is 1st element */ |
srv->srv_funcs = srv->srv_funcs->func_next; |
srv->srv_funcs = srv->srv_funcs->func_next; |
Line 226 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
Line 220 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
curr->func_next = curr->func_next->func_next; |
curr->func_next = curr->func_next->func_next; |
} |
} |
io_freeVars(&f->func_vars); |
io_freeVars(&f->func_vars); |
|
AIT_FREE_VAL(&f->func_name); |
|
AIT_FREE_VAL(&f->func_file); |
free(f); |
free(f); |
pthread_mutex_unlock(&srv->srv_mtx); |
pthread_mutex_unlock(&srv->srv_mtx); |
|
|
Line 268 rpc_srv_getCall(rpc_srv_t * __restrict srv, uint16_t t
|
Line 264 rpc_srv_getCall(rpc_srv_t * __restrict srv, uint16_t t
|
rpc_func_t * |
rpc_func_t * |
rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc) |
rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc) |
{ |
{ |
rpc_func_t func; | rpc_func_t func, *f = NULL; |
|
|
if (!srv || !csFunc) { |
if (!srv || !csFunc) { |
rpc_SetErr(EINVAL, "Invalid parameter can`t get function"); |
rpc_SetErr(EINVAL, "Invalid parameter can`t get function"); |
Line 280 rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char
|
Line 276 rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char
|
if (calcHashes(&func, csModule, csFunc) == -1) |
if (calcHashes(&func, csModule, csFunc) == -1) |
return NULL; |
return NULL; |
|
|
return rpc_srv_getCall(srv, func.func_tag, func.func_hash); | f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
| |
| AIT_FREE_VAL(&func.func_name); |
| AIT_FREE_VAL(&func.func_file); |
| return f; |
} |
} |
|
|
// --------------------------------------------------------- |
// --------------------------------------------------------- |