--- libaitrpc/src/srv.c 2013/09/05 00:34:23 1.19.2.2 +++ libaitrpc/src/srv.c 2013/11/13 12:18:43 1.20.4.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.19.2.2 2013/09/05 00:34:23 misho Exp $ +* $Id: srv.c,v 1.20.4.2 2013/11/13 12:18:43 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -269,7 +269,6 @@ execCall(sched_task_t *task) } else { /* if client doesn't want reply */ argc = RPC_CHK_NOREPLY(rpc); - rpc->call_req.flags ^= rpc->call_req.flags; rpc->call_rep.ret = RPC_ERROR(rpc_srv_execCall(c, rpc, f->func_name, arr)); if (rpc->call_rep.ret == htonl(-1)) { if (!rpc->call_rep.eno) { @@ -387,10 +386,17 @@ acceptClients(sched_task_t *task) rpc_srv_t *srv = TASK_ARG(task); rpc_cli_t *c = NULL; socklen_t salen = sizeof(sockaddr_t); + int sock; c = _allocClient(srv, NULL); - if (!c) + if (!c) { + EVERBOSE(1, "RPC client quota exceeded! Connection will be shutdown!\n"); + if ((sock = accept(TASK_FD(task), NULL, NULL)) != -1) { + shutdown(sock, SHUT_RDWR); + close(sock); + } goto end; + } /* accept client */ c->cli_sock = accept(TASK_FD(task), &c->cli_sa.sa, &salen); @@ -713,6 +719,7 @@ acceptBLOBClients(sched_task_t *task) rpc_cli_t *c = NULL; register int i; socklen_t salen = sizeof(sockaddr_t); + int sock; #ifdef TCP_NOPUSH int n = 1; #endif @@ -720,8 +727,15 @@ acceptBLOBClients(sched_task_t *task) /* check free slots for connect */ for (i = 0; i < array_Size(srv->srv_blob.clients) && (c = array(srv->srv_blob.clients, i, rpc_cli_t*)); i++); - if (c) /* no more free slots! */ + if (c) { /* no more free slots! */ + EVERBOSE(1, "BLOB client quota exceeded! Connection will be shutdown!\n"); + if ((sock = accept(TASK_FD(task), NULL, NULL)) != -1) { + shutdown(sock, SHUT_RDWR); + close(sock); + } goto end; + } + c = e_malloc(sizeof(rpc_cli_t)); if (!c) { LOGERR;