From: J. A. H. <j_...@us...> - 2003-07-05 16:13:30
|
Update of /cvsroot/slashem/slashem/win/proxy In directory sc8-pr-cvs1:/tmp/cvs-serv30482/win/proxy Modified Files: callback.c Log Message: Proxy: Relax limits on buffer sizes to improve download speed Index: callback.c =================================================================== RCS file: /cvsroot/slashem/slashem/win/proxy/callback.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** callback.c 5 Jul 2003 15:02:54 -0000 1.17 --- callback.c 5 Jul 2003 16:13:27 -0000 1.18 *************** *** 209,217 **** int fh, len; char *retval; ! char buf[512]; /* Must be small enough that packet fits into 1Kb */ extern char *dlbh_fgets(); nhext_rpc_params(request, 2, EXT_INT_P(len), EXT_INT_P(fh)); ! retval = dlbh_fgets(buf, len < 512 ? len : 512, fh); nhext_rpc_params(reply, 1, EXT_STRING(retval ? retval : "")); } --- 209,225 ---- int fh, len; char *retval; ! char *buf; extern char *dlbh_fgets(); nhext_rpc_params(request, 2, EXT_INT_P(len), EXT_INT_P(fh)); ! if (len > 10*1024*1024) ! len = 10*1024*1024; /* Avoid pointless resource useage */ ! buf = (char *)malloc(len); ! if (!buf && len > 512) { ! len = 512; ! buf = (char *)malloc(len); ! } ! retval = buf ? dlbh_fgets(buf, len, fh) : (char *)0; nhext_rpc_params(reply, 1, EXT_STRING(retval ? retval : "")); + free(buf); } *************** *** 222,232 **** { int fh, len, nb; ! char buf[512]; /* Must be small enough that packet fits into 1Kb */ nhext_rpc_params(request, 2, EXT_INT_P(len), EXT_INT_P(fh)); ! if (len > 512) len = 512; ! nb = dlbh_fread(buf, 1, len, fh); nhext_rpc_params(reply, 2, EXT_INT(nb < 0), EXT_BYTES(buf, nb >= 0 ? nb : 0)); } --- 230,246 ---- { int fh, len, nb; ! char *buf; nhext_rpc_params(request, 2, EXT_INT_P(len), EXT_INT_P(fh)); ! if (len > 10*1024*1024) ! len = 10*1024*1024; /* Avoid pointless resource useage */ ! buf = (char *)malloc(len); ! if (!buf && len > 512) { len = 512; ! buf = (char *)malloc(len); ! } ! nb = buf ? dlbh_fread(buf, 1, len, fh) : -1; nhext_rpc_params(reply, 2, EXT_INT(nb < 0), EXT_BYTES(buf, nb >= 0 ? nb : 0)); + free(buf); } |