[Linux-decnet-commit] CVS: dnprogs/dntask dntask.c,1.8,1.9
Brought to you by:
chrissie_c,
ph3-der-loewe
|
From: <chr...@us...> - 2008-10-04 10:22:37
|
Update of /cvsroot/linux-decnet/dnprogs/dntask In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11566 Modified Files: dntask.c Log Message: Add timeout Index: dntask.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dntask/dntask.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** dntask.c 20 Aug 2008 12:43:58 -0000 1.8 --- dntask.c 4 Oct 2008 10:22:29 -0000 1.9 *************** *** 1,5 **** /****************************************************************************** ! (c) 1998 Christine Caulfield chr...@go... ! K. Humborg ke...@av... This program is free software; you can redistribute it and/or modify --- 1,5 ---- /****************************************************************************** ! (c) 1998,2008 Christine Caulfield chr...@go... ! K. Humborg ke...@av... This program is free software; you can redistribute it and/or modify *************** *** 33,36 **** --- 33,37 ---- static int sockfd; static int timeout = 60; + static int connect_timeout = 20; struct sockaddr_dn sockaddr; *************** *** 160,163 **** --- 161,166 ---- int setup_link(void) { + struct timeval timeout = {connect_timeout,0}; + if ( (np=getnodebyname(node)) == NULL) { *************** *** 185,188 **** --- 188,194 ---- } + if (setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout))) + perror("Error setting snd timeout"); + // Provide access control and proxy information if (setsockopt(sockfd,DNPROTO_NSP,SO_CONACCESS,&accessdata, *************** *** 235,239 **** opterr = 0; optind = 0; ! while ((opt=getopt(argc,argv,"?hVibt:")) != EOF) { switch(opt) --- 241,245 ---- opterr = 0; optind = 0; ! while ((opt=getopt(argc,argv,"?hVibt:T:")) != EOF) { switch(opt) *************** *** 255,258 **** --- 261,268 ---- break; + case 'T': + connect_timeout = atoi(optarg); + break; + case 'V': printf("\ndntask from dntools version %s\n\n", VERSION); *************** *** 477,480 **** --- 487,491 ---- fprintf(f, " -i Interact with the command procedure\n"); fprintf(f, " -t Timeout (in seconds) for interactive command procedure input\n"); + fprintf(f, " -T Connect timeout (in seconds)\n"); fprintf(f, " -b Treat received data as binary data\n"); fprintf(f, " -? -h display this help message\n"); *************** *** 495,499 **** char *msg; ! if (getsockopt(sockfd, DNPROTO_NSP, DSO_DISDATA, &optdata, &len) == -1) { --- 506,510 ---- char *msg; ! if (errno == ETIMEDOUT || getsockopt(sockfd, DNPROTO_NSP, DSO_DISDATA, &optdata, &len) == -1) { |