Diff for /libaitrpc/src/builtin.c between versions 1.4 and 1.6.4.2

version 1.4, 2011/09/07 07:24:21 version 1.6.4.2, 2012/05/11 08:49:43
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 58  rpcServerClients(rpc_func_t *call, int ic, array_t *iv Line 58  rpcServerClients(rpc_func_t *call, int ic, array_t *iv
         int len;          int len;
         const char *str = NULL;          const char *str = NULL;
         char *val, wrk[INET6_ADDRSTRLEN];          char *val, wrk[INET6_ADDRSTRLEN];
         struct sockaddr_in *s;  
         struct sockaddr_in6 *s6;  
         struct sockaddr_un *su;  
   
         RPC_CALLBACK_CHECK_INPUT(call);          RPC_CALLBACK_CHECK_INPUT(call);
         if (!call->func_parent)          if (!call->func_parent)
Line 78  rpcServerClients(rpc_func_t *call, int ic, array_t *iv Line 75  rpcServerClients(rpc_func_t *call, int ic, array_t *iv
                 memset(val, 0, len);                  memset(val, 0, len);
   
         for (i = 0, cli = srv->srv_clients; i < srv->srv_numcli; i++, cli++) {          for (i = 0, cli = srv->srv_clients; i < srv->srv_numcli; i++, cli++) {
                if (!cli->cli_sa.sa_family)                if (!cli->cli_sa.sa.sa_family)
                         continue;                          continue;
   
                switch (cli->cli_sa.sa_family) {                switch (cli->cli_sa.sa.sa_family) {
                         case AF_INET:                          case AF_INET:
                                s = (struct sockaddr_in*) &cli->cli_sa;                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin.sin_addr, wrk, sizeof wrk);
                                str = inet_ntop(cli->cli_sa.sa_family, &s->sin_addr, wrk, sizeof wrk); 
                                 break;                                  break;
                         case AF_INET6:                          case AF_INET6:
                                s6 = (struct sockaddr_in6*) &cli->cli_sa;                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin6.sin6_addr, wrk, sizeof wrk);
                                str = inet_ntop(cli->cli_sa.sa_family, &s6->sin6_addr, wrk, sizeof wrk); 
                                 break;                                  break;
                         case AF_LOCAL:                          case AF_LOCAL:
                                su = (struct sockaddr_un*) &cli->cli_sa;                                str = cli->cli_sa.sun.sun_path;
                                str = su->sun_path; 
                                 break;                                  break;
                 }                  }
                 if (str)                  if (str)
Line 135  rpcServerCalls(rpc_func_t *call, int ic, array_t *iv) Line 129  rpcServerCalls(rpc_func_t *call, int ic, array_t *iv)
                 memset(val, 0, len);                  memset(val, 0, len);
   
         for (f = srv->srv_funcs, i = 0; f; f = f->func_next) {          for (f = srv->srv_funcs, i = 0; f; f = f->func_next) {
                if (*f->func_name) {                if (*AIT_GET_STR(&f->func_name)) {
                         memset(str, 0, sizeof str);                          memset(str, 0, sizeof str);
                        snprintf(str, sizeof str, "/%s/%s(%d); ",                         if (AIT_ISEMPTY(&f->func_file))
                                        f->func_file, f->func_name, io_arraySize(f->func_vars));                                snprintf(str, sizeof str, "/*/%s(%d); ", 
                                                 AIT_GET_STR(&f->func_name), io_arraySize(f->func_vars));
                         else
                                 snprintf(str, sizeof str, "/%s/%s(%d); ", AIT_GET_STR(&f->func_file), 
                                                 AIT_GET_STR(&f->func_name), io_arraySize(f->func_vars));
                         strlcat(val, str, len);                          strlcat(val, str, len);
                 }                  }
         }          }
Line 186  rpcServerShutdown(rpc_func_t *call, int ic, array_t *i Line 184  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;
 }  }
Line 206  rpcBLOBServerShutdown(rpc_func_t *call, int ic, array_ Line 202  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 240  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i Line 234  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 265  rpcBLOBServerVars(rpc_func_t *call, int ic, array_t *i Line 256  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 283  rpcBLOBServerState(rpc_func_t *call, int ic, array_t * Line 273  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 299  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t Line 287  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t
         int len;          int len;
         const char *str = NULL;          const char *str = NULL;
         char *val, wrk[INET6_ADDRSTRLEN];          char *val, wrk[INET6_ADDRSTRLEN];
         struct sockaddr_in *s;  
         struct sockaddr_in6 *s6;  
         struct sockaddr_un *su;  
   
         RPC_CALLBACK_CHECK_INPUT(call);          RPC_CALLBACK_CHECK_INPUT(call);
         if (!call->func_parent)          if (!call->func_parent)
Line 328  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t Line 313  rpcBLOBServerClients(rpc_func_t *call, int ic, array_t
                 memset(val, 0, len);                  memset(val, 0, len);
   
         for (i = 0, cli = srv->srv_blob.clients; i < srv->srv_numcli; i++, cli++) {          for (i = 0, cli = srv->srv_blob.clients; i < srv->srv_numcli; i++, cli++) {
                if (!cli->cli_sa.sa_family)                if (!cli->cli_sa.sa.sa_family)
                         continue;                          continue;
   
                switch (cli->cli_sa.sa_family) {                switch (cli->cli_sa.sa.sa_family) {
                         case AF_INET:                          case AF_INET:
                                s = (struct sockaddr_in*) &cli->cli_sa;                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin.sin_addr, wrk, sizeof wrk);
                                str = inet_ntop(cli->cli_sa.sa_family, &s->sin_addr, wrk, sizeof wrk); 
                                 break;                                  break;
                         case AF_INET6:                          case AF_INET6:
                                s6 = (struct sockaddr_in6*) &cli->cli_sa;                                str = inet_ntop(cli->cli_sa.sa.sa_family, &cli->cli_sa.sin6.sin6_addr, wrk, sizeof wrk);
                                str = inet_ntop(cli->cli_sa.sa_family, &s6->sin6_addr, wrk, sizeof wrk); 
                                 break;                                  break;
                         case AF_LOCAL:                          case AF_LOCAL:
                                su = (struct sockaddr_un*) &cli->cli_sa;                                str = cli->cli_sa.sun.sun_path;
                                str = su->sun_path; 
                                 break;                                  break;
                 }                  }
                 if (str)                  if (str)

Removed from v.1.4  
changed lines
  Added in v.1.6.4.2


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