Diff for /libaitrpc/src/srv.c between versions 1.30.2.11 and 1.32.2.1

version 1.30.2.11, 2024/03/20 16:53:08 version 1.32.2.1, 2025/03/31 12:18:40
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 - 2024Copyright 2004 - 2025
         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 543  rxUDPPacket(sched_task_t *task) Line 543  rxUDPPacket(sched_task_t *task)
 #endif  #endif
         rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b), 0, &sa.sa, &salen);          rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b), 0, &sa.sa, &salen);
         rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);          rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);
        if (rlen < sizeof(struct tagRPCCall))        if (!rpc || rlen < sizeof(struct tagRPCCall))
                 goto end;                  goto end;
         else          else
                 len = ntohl(rpc->call_len);                  len = ntohl(rpc->call_len);
Line 687  rxRAWPacket(sched_task_t *task) Line 687  rxRAWPacket(sched_task_t *task)
         if (sa.sa.sa_family == AF_INET) {          if (sa.sa.sa_family == AF_INET) {
                 struct ip *h;                  struct ip *h;
                 h = (struct ip*) AIT_GET_BUF(&b);                  h = (struct ip*) AIT_GET_BUF(&b);
                if (rlen < ntohs(h->ip_len) || h->ip_p != IPPROTO_ERPC)                if (!h || rlen < ntohs(h->ip_len) || h->ip_p != IPPROTO_ERPC)
                         goto end;                          goto end;
                 else {                  else {
                         rlen -= sizeof(struct ip);                          rlen -= sizeof(struct ip);
Line 697  rxRAWPacket(sched_task_t *task) Line 697  rxRAWPacket(sched_task_t *task)
 #ifdef IPV6_REMOVE_HEADER  #ifdef IPV6_REMOVE_HEADER
                 struct ip6_hdr *h;                  struct ip6_hdr *h;
                 h = (struct ip6_hdr*) AIT_GET_BUF(&b);                  h = (struct ip6_hdr*) AIT_GET_BUF(&b);
                if (rlen < ntohs(h->ip6_plen) || h->ip6_nxt != IPPROTO_ERPC)                if (!h || rlen < ntohs(h->ip6_plen) || h->ip6_nxt != IPPROTO_ERPC)
                         goto end;                          goto end;
                 else {                  else {
                         rlen -= sizeof(struct ip6_hdr);                          rlen -= sizeof(struct ip6_hdr);
Line 707  rxRAWPacket(sched_task_t *task) Line 707  rxRAWPacket(sched_task_t *task)
                 rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);                  rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);
 #endif  #endif
         }          }
        if (rlen < sizeof(struct tagRPCCall))        if (!rpc || rlen < sizeof(struct tagRPCCall))
                 goto end;                  goto end;
         else          else
                 len = ntohl(rpc->call_len);                  len = ntohl(rpc->call_len);
Line 1014  rxEXTPacket(sched_task_t *task) Line 1014  rxEXTPacket(sched_task_t *task)
         AIT_SET_BUF(&b, NULL, srv->srv_netbuf);          AIT_SET_BUF(&b, NULL, srv->srv_netbuf);
         rlen = read(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b));          rlen = read(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b));
         rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);          rpc = (struct tagRPCCall*) AIT_GET_BUF(&b);
        if (rlen < sizeof(struct tagRPCCall))        if (!rpc || rlen < sizeof(struct tagRPCCall))
                 goto end;                  goto end;
         else          else
                 len = ntohl(rpc->call_len);                  len = ntohl(rpc->call_len);
Line 1562  rpc_srv_initServer(u_char InstID, int concurentClients Line 1562  rpc_srv_initServer(u_char InstID, int concurentClients
         /* init functions */          /* init functions */
         pthread_mutex_init(&srv->srv_funcs.mtx, NULL);          pthread_mutex_init(&srv->srv_funcs.mtx, NULL);
         SLIST_INIT(&srv->srv_funcs);          SLIST_INIT(&srv->srv_funcs);
        AVL_INIT(&srv->srv_funcs);        RB_INIT(&srv->srv_funcs);
   
         /* init scheduler */          /* init scheduler */
         srv->srv_root = schedBegin();          srv->srv_root = schedBegin();
Line 1571  rpc_srv_initServer(u_char InstID, int concurentClients Line 1571  rpc_srv_initServer(u_char InstID, int concurentClients
                 pthread_mutex_destroy(&srv->srv_funcs.mtx);                  pthread_mutex_destroy(&srv->srv_funcs.mtx);
                 e_free(srv);                  e_free(srv);
                 return NULL;                  return NULL;
        } else        }
                schedSignalDispatch(srv->srv_root, 42); 
   
         /* init pool for clients */          /* init pool for clients */
         srv->srv_clients = array_Init(concurentClients);          srv->srv_clients = array_Init(concurentClients);
Line 1694  rpc_srv_loopServer(rpc_srv_t * __restrict srv) Line 1693  rpc_srv_loopServer(rpc_srv_t * __restrict srv)
         schedPolling(srv->srv_root, &ts, NULL);          schedPolling(srv->srv_root, &ts, NULL);
         /* main rpc loop */          /* main rpc loop */
         schedRun(srv->srv_root, &srv->srv_kill);          schedRun(srv->srv_root, &srv->srv_kill);
         schedSignalDispatch(srv->srv_root, 0);  
   
         /* close all clients connections & server socket */          /* close all clients connections & server socket */
         for (i = 0; i < array_Size(srv->srv_clients); i++) {          for (i = 0; i < array_Size(srv->srv_clients); i++) {
Line 1724  rpc_srv_loopServer(rpc_srv_t * __restrict srv) Line 1722  rpc_srv_loopServer(rpc_srv_t * __restrict srv)
                 AIT_FREE_VAL(&f->func_name);                  AIT_FREE_VAL(&f->func_name);
                 e_free(f);                  e_free(f);
         }          }
        srv->srv_funcs.avlh_root = NULL;        srv->srv_funcs.rbh_root = NULL;
         RPC_FUNCS_UNLOCK(&srv->srv_funcs);          RPC_FUNCS_UNLOCK(&srv->srv_funcs);
   
         return 0;          return 0;
Line 1824  rpc_srv_initServer2(u_char InstID, int concurentClient Line 1822  rpc_srv_initServer2(u_char InstID, int concurentClient
         /* init functions */          /* init functions */
         pthread_mutex_init(&srv->srv_funcs.mtx, NULL);          pthread_mutex_init(&srv->srv_funcs.mtx, NULL);
         SLIST_INIT(&srv->srv_funcs);          SLIST_INIT(&srv->srv_funcs);
        AVL_INIT(&srv->srv_funcs);        RB_INIT(&srv->srv_funcs);
   
         /* init scheduler */          /* init scheduler */
         srv->srv_root = schedBegin();          srv->srv_root = schedBegin();
Line 1833  rpc_srv_initServer2(u_char InstID, int concurentClient Line 1831  rpc_srv_initServer2(u_char InstID, int concurentClient
                 pthread_mutex_destroy(&srv->srv_funcs.mtx);                  pthread_mutex_destroy(&srv->srv_funcs.mtx);
                 e_free(srv);                  e_free(srv);
                 return NULL;                  return NULL;
        } else        }
                schedSignalDispatch(srv->srv_root, 42); 
   
         /* init pool for clients */          /* init pool for clients */
         srv->srv_clients = array_Init(concurentClients);          srv->srv_clients = array_Init(concurentClients);
Line 1943  rpc_srv_initServerExt(u_char InstID, int netBuf, int f Line 1940  rpc_srv_initServerExt(u_char InstID, int netBuf, int f
         /* init functions */          /* init functions */
         pthread_mutex_init(&srv->srv_funcs.mtx, NULL);          pthread_mutex_init(&srv->srv_funcs.mtx, NULL);
         SLIST_INIT(&srv->srv_funcs);          SLIST_INIT(&srv->srv_funcs);
        AVL_INIT(&srv->srv_funcs);        RB_INIT(&srv->srv_funcs);
   
         /* init scheduler */          /* init scheduler */
         srv->srv_root = schedBegin();          srv->srv_root = schedBegin();
Line 1952  rpc_srv_initServerExt(u_char InstID, int netBuf, int f Line 1949  rpc_srv_initServerExt(u_char InstID, int netBuf, int f
                 pthread_mutex_destroy(&srv->srv_funcs.mtx);                  pthread_mutex_destroy(&srv->srv_funcs.mtx);
                 e_free(srv);                  e_free(srv);
                 return NULL;                  return NULL;
        } else        }
                schedSignalDispatch(srv->srv_root, 42); 
   
         /* init pool for clients */          /* init pool for clients */
         srv->srv_clients = array_Init(1);          srv->srv_clients = array_Init(1);

Removed from v.1.30.2.11  
changed lines
  Added in v.1.32.2.1


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