]> arthur.barton.de Git - netatalk.git/commitdiff
Performance tuning in afp_read: factor out an unneccessary filesytem read when sendfi...
authorFrank Lahm <franklahm@googlemail.com>
Fri, 11 Nov 2011 14:07:29 +0000 (15:07 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 11 Nov 2011 14:07:29 +0000 (15:07 +0100)
etc/afpd/fork.c
include/atalk/util.h
libatalk/dsi/dsi_read.c

index 4c70cdbed7935ad3ee80e11606b63d34c43ce8b6..2e235888590e5eed2ebe143ccb91b732f8361bf4 100644 (file)
@@ -844,7 +844,9 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
     int                        eid, xlate = 0;
     u_int16_t          ofrefnum;
     u_char             nlmask, nlchar;
-    
+
+    *rbuflen = 0;
+
     ibuf += 2;
     memcpy(&ofrefnum, ibuf, sizeof( ofrefnum ));
     ibuf += sizeof( u_short );
@@ -900,12 +902,12 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
         goto afp_read_err;
     }
 
-#define min(a,b)       ((a)<(b)?(a):(b))
-    *rbuflen = min( reqcount, *rbuflen );
+#ifndef WITH_SENDFILE
+    *rbuflen = MIN(reqcount, *rbuflen);
     err = read_file(ofork, eid, offset, nlmask, nlchar, rbuf, rbuflen, xlate);
     if (err < 0)
         goto afp_read_done;
-
+#endif
     /* dsi can stream requests. we can only do this if we're not checking
      * for an end-of-line character. oh well. */
     if ((obj->proto == AFPPROTO_DSI) && (*rbuflen < reqcount) && !nlmask) {
index 9b0a405f31b96dcc82fcd356f8a0631e5e72a170..3a6dd24498bb85e7e66c84800f4edb633ca26aeb 100644 (file)
 #endif /* NDEBUG */
 
 #define STRCMP(a,b,c) (strcmp(a,c) b 0)
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? a : b)
+#endif
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? a : b)
+#endif
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define hton64(x)       (x)
index fc86c0a1339944d011cecc7c10b8fbbbcc88ea44..092544ad3198f51b24354863561941b409709f57 100644 (file)
 #endif
 
 #include <atalk/dsi.h>
-
-#ifndef min
-#define min(a,b)   ((a) < (b) ? (a) : (b))
-#endif /* ! min */
+#include <atalk/util.h>
 
 /* streaming i/o for afp_read. this is all from the perspective of the
  * client. it basically does the reverse of dsi_write. on first entry,
@@ -45,7 +42,7 @@ ssize_t dsi_readinit(DSI *dsi, void *buf, const size_t buflen,
   dsi->in_write++;
   if (dsi_stream_send(dsi, buf, buflen)) {
     dsi->datasize = size - buflen;
-    return min(dsi->datasize, buflen);
+    return MIN(dsi->datasize, buflen);
   }
 
   return -1; /* error */
@@ -65,7 +62,7 @@ ssize_t dsi_read(DSI *dsi, void *buf, const size_t buflen)
 
   if (len == buflen) {
     dsi->datasize -= len;
-    return min(dsi->datasize, buflen);
+    return MIN(dsi->datasize, buflen);
   }
 
   return -1;