Diff for /libaitrpc/src/builtin.c between versions 1.5 and 1.7.2.1

version 1.5, 2011/11/03 15:32:21 version 1.7.2.1, 2012/05/15 23:28:20
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 52  int Line 52  int
 rpcServerClients(rpc_func_t *call, int ic, array_t *iv)  rpcServerClients(rpc_func_t *call, int ic, array_t *iv)
 {  {
         rpc_srv_t *srv;          rpc_srv_t *srv;
         array_t *vals;  
         rpc_cli_t *cli;          rpc_cli_t *cli;
         register int i;          register int i;
         int len;          int len;
         const char *str = NULL;          const char *str = NULL;
        char *val, wrk[INET6_ADDRSTRLEN];        char *val;
         ait_val_t v;
   
         RPC_CALLBACK_CHECK_INPUT(call);          RPC_CALLBACK_CHECK_INPUT(call);
         if (!call->func_parent)          if (!call->func_parent)
Line 65  rpcServerClients(rpc_func_t *call, int ic, array_t *iv Line 65  rpcServerClients(rpc_func_t *call, int ic, array_t *iv
         else          else
                 srv = call->func_parent;                  srv = call->func_parent;
   
        rpc_srv_getVars(call, &vals);        len = io_arraySize(srv->srv_clients) * STRSIZ;
 
        len = srv->srv_numcli * STRSIZ; 
         if (!(val = malloc(len))) {          if (!(val = malloc(len))) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
         } else          } else
                 memset(val, 0, len);                  memset(val, 0, len);
   
        for (i = 0, cli = srv->srv_clients; i < srv->srv_numcli; i++, cli++) {        for (i = 0; i < io_arraySize(srv->srv_clients); i++) {
                if (!cli->cli_sa.sa.sa_family)                cli = io_array(srv->srv_clients, i, rpc_cli_t*);
                 if (!cli)
                         continue;                          continue;
   
                switch (cli->cli_sa.sa.sa_family) {                str = io_n2addr(&cli->cli_sa, &v);
                        case AF_INET: 
                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin.sin_addr, wrk, sizeof wrk); 
                                break; 
                        case AF_INET6: 
                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin6.sin6_addr, wrk, sizeof wrk); 
                                break; 
                        case AF_LOCAL: 
                                str = cli->cli_sa.sun.sun_path; 
                                break; 
                } 
                 if (str)                  if (str)
                         strlcat(val, (char*) str, len);                          strlcat(val, (char*) str, len);
                 else                  else
                         strlcat(val, "0.0.0.0", len);                          strlcat(val, "0.0.0.0", len);
                 strlcat(val, " ", len);                  strlcat(val, " ", len);
                   AIT_FREE_VAL(&v);
         }          }
   
        AIT_SET_STR(io_array(vals, 0, ait_val_t*), val);        AIT_SET_STR(io_array(call->func_vars, 0, ait_val_t*), val);
         free(val);          free(val);
         return 0;          return 0;
 }  }
Line 105  int Line 95  int
 rpcServerCalls(rpc_func_t *call, int ic, array_t *iv)  rpcServerCalls(rpc_func_t *call, int ic, array_t *iv)
 {  {
         rpc_srv_t *srv;          rpc_srv_t *srv;
         array_t *vals;  
         rpc_func_t *f;          rpc_func_t *f;
        register int i;        register int i = 0;
         int len;          int len;
         char *val, str[MAXPATHLEN];          char *val, str[MAXPATHLEN];
   
Line 117  rpcServerCalls(rpc_func_t *call, int ic, array_t *iv) Line 106  rpcServerCalls(rpc_func_t *call, int ic, array_t *iv)
         else          else
                 srv = call->func_parent;                  srv = call->func_parent;
   
        for (i = 0, f = srv->srv_funcs; f; i++, f = f->func_next);        TAILQ_FOREACH(f, &srv->srv_funcs, func_node)
                 i++;
         len = i * STRSIZ;          len = i * STRSIZ;
   
         rpc_srv_getVars(call, &vals);  
   
         if (!(val = malloc(len))) {          if (!(val = malloc(len))) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
         } else          } else
                 memset(val, 0, len);                  memset(val, 0, len);
   
        for (f = srv->srv_funcs, i = 0; f; f = f->func_next) {        TAILQ_FOREACH(f, &srv->srv_funcs, func_node)
                if (*f->func_name) {                if (AIT_ADDR(&f->func_name)) {
                         memset(str, 0, sizeof str);                          memset(str, 0, sizeof str);
                        snprintf(str, sizeof str, "/%s/%s(%d); ",                         snprintf(str, sizeof str, "/%hu/0x%p(%d); ", AIT_KEY(&f->func_name), 
                                        *f->func_file ? f->func_file : "*",                                         AIT_ADDR(&f->func_name), io_arraySize(f->func_vars));
                                        f->func_name, io_arraySize(f->func_vars)); 
                         strlcat(val, str, len);                          strlcat(val, str, len);
                 }                  }
         }  
   
        AIT_SET_STR(io_array(vals, 0, ait_val_t*), val);        AIT_SET_STR(io_array(f->func_vars, 0, ait_val_t*), val);
         free(val);          free(val);
         return 0;          return 0;
 }  }
Line 147  int Line 133  int
 rpcServerSessions(rpc_func_t *call, int ic, array_t *iv)  rpcServerSessions(rpc_func_t *call, int ic, array_t *iv)
 {  {
         rpc_srv_t *srv;          rpc_srv_t *srv;
         array_t *vals;  
         ait_val_t *v;          ait_val_t *v;
   
         RPC_CALLBACK_CHECK_INPUT(call);          RPC_CALLBACK_CHECK_INPUT(call);
Line 156  rpcServerSessions(rpc_func_t *call, int ic, array_t *i Line 141  rpcServerSessions(rpc_func_t *call, int ic, array_t *i
         else          else
                 srv = call->func_parent;                  srv = call->func_parent;
   
        rpc_srv_getVars(call, &vals);        v = io_array(call->func_vars, 0, ait_val_t*);
 
        v = io_array(vals, 0, ait_val_t*); 
         AIT_SET_U8(v, srv->srv_session.sess_version);          AIT_SET_U8(v, srv->srv_session.sess_version);
        v = io_array(vals, 1, ait_val_t*);        v = io_array(call->func_vars, 1, ait_val_t*);
         AIT_SET_U32(v, srv->srv_session.sess_program);          AIT_SET_U32(v, srv->srv_session.sess_program);
        v = io_array(vals, 2, ait_val_t*);        v = io_array(call->func_vars, 2, ait_val_t*);
        AIT_SET_U32(v, srv->srv_session.sess_process);        AIT_SET_U8(v, srv->srv_session.sess_process);
        v = io_array(vals, 3, ait_val_t*);        v = io_array(call->func_vars, 3, ait_val_t*);
        AIT_SET_I32(v, srv->srv_numcli);        AIT_SET_I32(v, io_arraySize(srv->srv_clients));
   
         return 0;          return 0;
 }  }
Line 181  rpcServerShutdown(rpc_func_t *call, int ic, array_t *i Line 164  rpcServerShutdown(rpc_func_t *call, int ic, array_t *i
         else          else
                 srv = call->func_parent;                  srv = call->func_parent;
   
         pthread_mutex_lock(&srv->srv_mtx);  
         srv->srv_kill = kill;          srv->srv_kill = kill;
         pthread_mutex_unlock(&srv->srv_mtx);  
   
         return 0;          return 0;
 }  }
   
// ----------------------------------------------------/* ---------------------------------------------------- */
   
   #if 0
 int  int
 rpcBLOBServerShutdown(rpc_func_t *call, int ic, array_t *iv)  rpcBLOBServerShutdown(rpc_func_t *call, int ic, array_t *iv)
 {  {
Line 201  rpcBLOBServerShutdown(rpc_func_t *call, int ic, array_ Line 183  rpcBLOBServerShutdown(rpc_func_t *call, int ic, array_
         else          else
                 srv = call->func_parent;                  srv = call->func_parent;
   
         pthread_mutex_lock(&srv->srv_blob.mtx);  
         srv->srv_blob.state = kill;          srv->srv_blob.state = kill;
         pthread_mutex_unlock(&srv->srv_blob.mtx);  
   
         return 0;          return 0;
 }  }
Line 235  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i Line 215  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i
                 return 1;                  return 1;
         }          }
   
         pthread_mutex_lock(&srv->srv_blob.mtx);  
         for (i = 0, b = srv->srv_blob.blobs; b; i++, b = b->blob_next);          for (i = 0, b = srv->srv_blob.blobs; b; i++, b = b->blob_next);
         len = i * sizeof str;          len = i * sizeof str;
   
         if (!len) {          if (!len) {
                 AIT_SET_STR(io_array(vals, 0, ait_val_t*), "");                  AIT_SET_STR(io_array(vals, 0, ait_val_t*), "");
                 pthread_mutex_unlock(&srv->srv_blob.mtx);  
                 return 0;                  return 0;
         }          }
   
         if (!(val = malloc(len))) {          if (!(val = malloc(len))) {
                 LOGERR;                  LOGERR;
                 pthread_mutex_unlock(&srv->srv_blob.mtx);  
                 return -1;                  return -1;
         } else          } else
                 memset(val, 0, len);                  memset(val, 0, len);
Line 260  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i Line 237  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i
   
         AIT_SET_STR(io_array(vals, 0, ait_val_t*), val);          AIT_SET_STR(io_array(vals, 0, ait_val_t*), val);
         free(val);          free(val);
         pthread_mutex_unlock(&srv->srv_blob.mtx);  
         return 0;          return 0;
 }  }
   
Line 278  rpcBLOBServerState(rpc_func_t *call, int ic, array_t * Line 254  rpcBLOBServerState(rpc_func_t *call, int ic, array_t *
         if (AIT_TYPE(io_array(iv, 0, ait_val_t*)) != i32)          if (AIT_TYPE(io_array(iv, 0, ait_val_t*)) != i32)
                 return -1;                  return -1;
   
         pthread_mutex_lock(&srv->srv_mtx);  
         srv->srv_blob.state = AIT_GET_I32(io_array(iv, 0, ait_val_t*));          srv->srv_blob.state = AIT_GET_I32(io_array(iv, 0, ait_val_t*));
         pthread_mutex_unlock(&srv->srv_mtx);  
         return 0;          return 0;
 }  }
   
Line 345  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t Line 319  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t
         free(val);          free(val);
         return 0;          return 0;
 }  }
   #endif

Removed from v.1.5  
changed lines
  Added in v.1.7.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>