netpoll.c: upped default packet size
authorArt Cancro <ajc@citadel.org>
Wed, 28 Apr 1999 13:52:30 +0000 (13:52 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 28 Apr 1999 13:52:30 +0000 (13:52 +0000)
citadel/ChangeLog
citadel/netpoll.c

index bff4fe43b58ef0d544c8ddd70fb5c4ec8fb1d3de..0ca58c2f1423cd402b0a1b2ede777c58802bbef1 100644 (file)
@@ -1,6 +1,7 @@
 1999-04-27 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * file_ops.c: fixed NDOP to not crash the server if it has trouble
          with a download file
+       * netpoll.c: upped default packet size
 
 Mon Apr 26 22:06:57 EDT 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Repaired IGnorant security hole blunder re. citmail
index ef7fca1be8bd5e38500f646b6f4c95e8a54a96fa..d9d018cefe73785c8da6f187343fec51f31eb60a 100644 (file)
@@ -14,7 +14,7 @@
  * up on larger packet sizes.  We don't know why.  In any case, never set the
  * packet size higher than 4096 or your server sessions will crash.
  */
-#define IGNET_PACKET_SIZE 64
+#define IGNET_PACKET_SIZE 4000
 
 long atol(const char *);
 
@@ -28,13 +28,14 @@ struct config config;
 void logoff(int code)
 {
        exit(code);
-       }
+}
 
 
 /*
  * receive network spool from the remote system
  */
-void receive_spool(void) {
+void receive_spool(void)
+{
        long download_len;
        long bytes_received;
        char buf[256];
@@ -43,44 +44,44 @@ void receive_spool(void) {
        long plen;
        FILE *fp;
 
-       sprintf(tempfilename,"/tmp/netpoll.%ld",(long)getpid());
+       sprintf(tempfilename, "/tmp/netpoll.%ld", (long) getpid());
        serv_puts("NDOP");
        serv_gets(buf);
-       printf("%s\n",buf);
-       if (buf[0]!='2') return;
-       download_len = extract_long(&buf[4],0);
+       printf("%s\n", buf);
+       if (buf[0] != '2')
+               return;
+       download_len = extract_long(&buf[4], 0);
 
        bytes_received = 0L;
-       fp = fopen(tempfilename,"w");
-       if (fp==NULL) {
+       fp = fopen(tempfilename, "w");
+       if (fp == NULL) {
                perror("cannot open download file locally");
                return;
-               }
-
+       }
        while (bytes_received < download_len) {
-               sprintf(buf,"READ %ld|%ld",
+               sprintf(buf, "READ %ld|%ld",
                        bytes_received,
-                       ( (download_len - bytes_received > IGNET_PACKET_SIZE)
-                         ? IGNET_PACKET_SIZE : (download_len - bytes_received) ) );
+                    ((download_len - bytes_received > IGNET_PACKET_SIZE)
+                ? IGNET_PACKET_SIZE : (download_len - bytes_received)));
                serv_puts(buf);
                serv_gets(buf);
-               if (buf[0]=='6') {
-                       plen = extract_long(&buf[4],0);
-                       serv_read(pbuf,plen);
-                       fwrite((char *)pbuf,plen,1,fp);
+               if (buf[0] == '6') {
+                       plen = extract_long(&buf[4], 0);
+                       serv_read(pbuf, plen);
+                       fwrite((char *) pbuf, plen, 1, fp);
                        bytes_received = bytes_received + plen;
-                       }
                }
+       }
 
        fclose(fp);
        serv_puts("CLOS");
        serv_gets(buf);
-       printf("%s\n",buf);
-       sprintf(buf,"mv %s %s/network/spoolin/netpoll.%ld",
-               tempfilename,BBSDIR,(long)getpid());
+       printf("%s\n", buf);
+       sprintf(buf, "mv %s %s/network/spoolin/netpoll.%ld",
+               tempfilename, BBSDIR, (long) getpid());
        system(buf);
        system("exec nohup ./netproc >/dev/null 2>&1 &");
-       }
+}
 
 /*
  * transmit network spool to the remote system
@@ -96,45 +97,44 @@ void transmit_spool(char *remote_nodename)
 
        serv_puts("NUOP");
        serv_gets(buf);
-       printf("%s\n",buf);
-       if (buf[0]!='2') return;
+       printf("%s\n", buf);
+       if (buf[0] != '2')
+               return;
 
-       sprintf(sfname,"%s/network/spoolout/%s",BBSDIR,remote_nodename);
-       fd = open(sfname,O_RDONLY);
-       if (fd<0) {
+       sprintf(sfname, "%s/network/spoolout/%s", BBSDIR, remote_nodename);
+       fd = open(sfname, O_RDONLY);
+       if (fd < 0) {
                if (errno == ENOENT) {
                        printf("Nothing to send.\n");
-                       }
-               else {
+               } else {
                        perror("cannot open upload file locally");
-                       }
-               return;
                }
-
-       while ( plen=(long)read(fd,pbuf,IGNET_PACKET_SIZE), plen>0L) {
-               bytes_to_write = plen; 
+               return;
+       }
+       while (plen = (long) read(fd, pbuf, IGNET_PACKET_SIZE), plen > 0L) {
+               bytes_to_write = plen;
                while (bytes_to_write > 0L) {
-                       sprintf(buf,"WRIT %ld", bytes_to_write);
+                       sprintf(buf, "WRIT %ld", bytes_to_write);
                        serv_puts(buf);
                        serv_gets(buf);
                        thisblock = atol(&buf[4]);
-                       if (buf[0]=='7') {
-                               serv_write(pbuf, (int)thisblock);
+                       if (buf[0] == '7') {
+                               serv_write(pbuf, (int) thisblock);
                                bytes_to_write = bytes_to_write - thisblock;
-                               }
-                       else {
+                       } else {
                                goto ABORTUPL;
-                               }
                        }
                }
+       }
 
 ABORTUPL:
        close(fd);
        serv_puts("UCLS 1");
        serv_gets(buf);
-       printf("%s\n",buf);
-       if (buf[0]=='2') unlink(sfname);
-       }
+       printf("%s\n", buf);
+       if (buf[0] == '2')
+               unlink(sfname);
+}
 
 
 
@@ -147,51 +147,51 @@ int main(int argc, char **argv)
 
        if (argc != 4) {
                fprintf(stderr,
-               "%s: usage: %s <address> <port number> <remote netpassword>\n",
-                       argv[0],argv[0]);
+                       "%s: usage: %s <address> <port number> <remote netpassword>\n",
+                       argv[0], argv[0]);
                exit(1);
-               }
-
+       }
        get_config();
 
-       attach_to_server(argc,argv);
+       attach_to_server(argc, argv);
        serv_gets(buf);
-       printf("%s\n",buf);
-       if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
-               fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
+       printf("%s\n", buf);
+       if ((buf[0] != '2') && (strncmp(buf, "551", 3))) {
+               fprintf(stderr, "%s: %s\n", argv[0], &buf[4]);
                logoff(atoi(buf));
-               }
-
+       }
        serv_puts("INFO");
        serv_gets(buf);
-       if (buf[0]=='1') {
+       if (buf[0] == '1') {
                a = 0;
-               while (serv_gets(buf), strcmp(buf,"000")) {
-                       if (a==1) strcpy(remote_nodename,buf);
-                       if (a==1) printf("Connected to: %s ",buf);
-                       if (a==2) printf("(%s) ",buf);
-                       if (a==6) printf("%s\n",buf);
+               while (serv_gets(buf), strcmp(buf, "000")) {
+                       if (a == 1)
+                               strcpy(remote_nodename, buf);
+                       if (a == 1)
+                               printf("Connected to: %s ", buf);
+                       if (a == 2)
+                               printf("(%s) ", buf);
+                       if (a == 6)
+                               printf("%s\n", buf);
                        ++a;
-                       }
-               }
-
-       if (!strcmp(remote_nodename,config.c_nodename)) {
-               fprintf(stderr,"Connected to local system\n");
                }
-       else {
-               sprintf(buf,"NETP %s|%s",config.c_nodename,argv[3]);
+       }
+       if (!strcmp(remote_nodename, config.c_nodename)) {
+               fprintf(stderr, "Connected to local system\n");
+       } else {
+               sprintf(buf, "NETP %s|%s", config.c_nodename, argv[3]);
                serv_puts(buf);
                serv_gets(buf);
-               printf("%s\n",buf);
-       
+               printf("%s\n", buf);
+
                /* only do the transfers if we authenticated correctly! */
-               if (buf[0]=='2') {
+               if (buf[0] == '2') {
                        receive_spool();
                        transmit_spool(remote_nodename);
-                       }
                }
+       }
 
        serv_puts("QUIT");
        serv_gets(buf);
        exit(0);
-       }
+}