--- libaitrpc/src/builtin.c 2011/09/06 23:58:48 1.3.2.8 +++ libaitrpc/src/builtin.c 2011/09/07 07:24:21 1.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: builtin.c,v 1.3.2.8 2011/09/06 23:58:48 misho Exp $ +* $Id: builtin.c,v 1.4 2011/09/07 07:24:21 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -229,11 +229,26 @@ rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i else srv = call->func_parent; + rpc_srv_getVars(call, &vals); + + if (srv->srv_blob.state == kill) { + AIT_SET_STR(io_array(vals, 0, ait_val_t*), "BLOB Server is killed"); + return 1; + } + if (srv->srv_blob.state == disable) { + AIT_SET_STR(io_array(vals, 0, ait_val_t*), "BLOB Server is disabled"); + return 1; + } + pthread_mutex_lock(&srv->srv_blob.mtx); for (i = 0, b = srv->srv_blob.blobs; b; i++, b = b->blob_next); len = i * sizeof str; - rpc_srv_getVars(call, &vals); + if (!len) { + AIT_SET_STR(io_array(vals, 0, ait_val_t*), ""); + pthread_mutex_unlock(&srv->srv_blob.mtx); + return 0; + } if (!(val = malloc(len))) { LOGERR; @@ -244,7 +259,7 @@ rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i for (b = srv->srv_blob.blobs, i = 0; b; i++, b = b->blob_next) { memset(str, 0, sizeof str); - snprintf(str, sizeof str, "0x%0X(%lu)=%p ", b->blob_var, b->blob_len, b->blob_data); + snprintf(str, sizeof str, "0x%0X(%lu)=%p ", b->blob_var, (u_long) b->blob_len, b->blob_data); strlcat(val, str, len); } @@ -295,6 +310,15 @@ rpcBLOBServerClients(rpc_func_t *call, int ic, array_t srv = call->func_parent; rpc_srv_getVars(call, &vals); + + if (srv->srv_blob.state == kill) { + AIT_SET_STR(io_array(vals, 0, ait_val_t*), "BLOB Server is killed"); + return 1; + } + if (srv->srv_blob.state == disable) { + AIT_SET_STR(io_array(vals, 0, ait_val_t*), "BLOB Server is disabled"); + return 1; + } len = srv->srv_numcli * STRSIZ; if (!(val = malloc(len))) {