From: Vlad S. <ser...@us...> - 2005-06-09 21:31:40
|
Update of /cvsroot/naviserver/modules/nsudp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2559/nsudp Modified Files: nsudp.c Log Message: rewrote nssnmp's ns_udp using new Objv interface, added to nsudp's ns_udp -retries parameter. Index: nsudp.c =================================================================== RCS file: /cvsroot/naviserver/modules/nsudp/nsudp.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** nsudp.c 20 May 2005 20:34:32 -0000 1.1.1.1 --- nsudp.c 9 Jun 2005 21:31:30 -0000 1.2 *************** *** 169,177 **** int salen = sizeof(sa); char *address = 0, *data = 0; ! int sock, len, port, timeout = 5, noreply = 0; Ns_ObjvSpec opts[] = { {"-timeout", Ns_ObjvInt, &timeout, NULL}, {"-noreply", Ns_ObjvInt, &noreply, NULL}, {"--", Ns_ObjvBreak, NULL, NULL}, {NULL, NULL, NULL, NULL} --- 169,178 ---- int salen = sizeof(sa); char *address = 0, *data = 0; ! int sock, len, port, timeout = 5, retries = 1, noreply = 0; Ns_ObjvSpec opts[] = { {"-timeout", Ns_ObjvInt, &timeout, NULL}, {"-noreply", Ns_ObjvInt, &noreply, NULL}, + {"-retries", Ns_ObjvInt, &retries, NULL}, {"--", Ns_ObjvBreak, NULL, NULL}, {NULL, NULL, NULL, NULL} *************** *** 197,200 **** --- 198,202 ---- return TCL_ERROR; } + resend: if (sendto(sock, data, len, 0,(struct sockaddr*)&sa,sizeof(sa)) < 0) { Tcl_AppendResult(interp, "sendto error ", strerror(errno), 0); *************** *** 207,211 **** memset(buf,0,sizeof(buf)); Ns_SockSetNonBlocking(sock); ! again: FD_ZERO(&fds); FD_SET(sock,&fds); --- 209,213 ---- memset(buf,0,sizeof(buf)); Ns_SockSetNonBlocking(sock); ! wait: FD_ZERO(&fds); FD_SET(sock,&fds); *************** *** 216,220 **** case -1: if (errno == EINTR || errno == EINPROGRESS || errno == EAGAIN) { ! goto again; } Tcl_AppendResult(interp, "select error ", strerror(errno), 0); --- 218,222 ---- case -1: if (errno == EINTR || errno == EINPROGRESS || errno == EAGAIN) { ! goto wait; } Tcl_AppendResult(interp, "select error ", strerror(errno), 0); *************** *** 223,226 **** --- 225,231 ---- case 0: + if(--retries < 0) { + goto resend; + } Tcl_AppendResult(interp, "timeout", 0); close(sock); |