]> arthur.barton.de Git - netatalk.git/commitdiff
Merge branch 'branch-netatalk-3-0' into develop
authorRalph Boehme <sloowfranklin@gmail.com>
Thu, 18 Apr 2013 10:04:59 +0000 (12:04 +0200)
committerRalph Boehme <sloowfranklin@gmail.com>
Thu, 18 Apr 2013 10:04:59 +0000 (12:04 +0200)
etc/afpd/fce_api.c
etc/afpd/fork.c
libatalk/dsi/dsi_stream.c
libatalk/util/socket.c

index 36cce446645883bd42214deb765609094a85dbe3..4620378922d763010ac006a700670f5fd194fdc1 100644 (file)
@@ -424,6 +424,8 @@ static void check_saved_close_events(int fmodwait)
  * */
 void fce_pending_events(AFPObj *obj)
 {
+    if (!udp_sockets)
+        return;
     check_saved_close_events(obj->options.fce_fmodwait);
 }
 
index 0c988828d609660bc096c8cf01c944f6f8e633dc..a77c6adcad5d826c54bc457f4b01ac1111798c1a 100644 (file)
@@ -759,7 +759,7 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 {
     DSI          *dsi = obj->dsi;
     struct ofork *ofork;
-    off_t        offset, saveoff, reqcount, savereqcount, size;
+    off_t        offset, saveoff, reqcount, savereqcount;
     ssize_t      cc, err;
     int          eid;
     uint16_t     ofrefnum;
@@ -801,23 +801,9 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 
     AFP_READ_START((long)reqcount);
 
-    /* reqcount isn't always truthful. we need to deal with that. */
-    size = ad_size(ofork->of_ad, eid);
-
     LOG(log_debug, logtype_afpd,
-        "afp_read(fork: %" PRIu16 " [%s], off: %" PRIu64 ", len: %" PRIu64 ", size: %" PRIu64 ")",
-        ofork->of_refnum, (ofork->of_flags & AFPFORK_DATA) ? "data" : "reso", offset, reqcount, size);
-
-    if (offset >= size) {
-        err = AFPERR_EOF;
-        goto afp_read_err;
-    }
-
-    /* subtract off the offset */
-    if (reqcount + offset > size) {
-        reqcount = size - offset;
-        err = AFPERR_EOF;
-    }
+        "afp_read(fork: %" PRIu16 " [%s], off: %" PRIu64 ", len: %" PRIu64 ")",
+        ofork->of_refnum, (ofork->of_flags & AFPFORK_DATA) ? "data" : "reso", offset, reqcount);
 
     savereqcount = reqcount;
     saveoff = offset;
index 05c36fc8eaf290e06b62496f26ed60f6e8b8bce9..94890dd8014341bbe6ccb02393f35a5456c9775c 100644 (file)
@@ -185,7 +185,7 @@ static ssize_t buf_read(DSI *dsi, uint8_t *buf, size_t count)
     if (len)
         return len;             /* 2. */
   
-    len = readt(dsi->socket, buf, count, 0, 1); /* 3. */
+    len = readt(dsi->socket, buf, count, 0, 0); /* 3. */
 
     LOG(log_maxdebug, logtype_dsi, "buf_read(%u bytes): got: %d", count, len);
 
index 6a78c8e22a9a10fd7a802e024c92cf53063c4af3..acea8ad39218dfa03fa6ec828abf4030c25433db 100644 (file)
@@ -79,7 +79,7 @@ int setnonblock(int fd, int cmd)
  * @param lenght          (r)  how many bytes to read
  * @param setnonblocking  (r)  when non-zero this func will enable and disable non blocking
  *                             io mode for the socket
- * @param timeout         (r)  number of seconds to try reading
+ * @param timeout         (r)  number of seconds to try reading, 0 means no timeout
  *
  * @returns number of bytes actually read or -1 on timeout or error
  */
@@ -99,9 +99,11 @@ ssize_t readt(int socket, void *data, const size_t length, int setnonblocking, i
     }
 
     /* Calculate end time */
-    (void)gettimeofday(&now, NULL);
-    end = now;
-    end.tv_sec += timeout;
+    if (timeout) {
+        (void)gettimeofday(&now, NULL);
+        end = now;
+        end.tv_sec += timeout;
+    }
 
     while (stored < length) {
         len = recv(socket, (char *) data + stored, length - stored, 0);
@@ -111,10 +113,12 @@ ssize_t readt(int socket, void *data, const size_t length, int setnonblocking, i
                 continue;
             case EAGAIN:
                 FD_SET(socket, &rfds);
-                tv.tv_usec = 0;
-                tv.tv_sec  = timeout;
-                        
-                while ((ret = select(socket + 1, &rfds, NULL, NULL, &tv)) < 1) {
+                if (timeout) {
+                    tv.tv_usec = 0;
+                    tv.tv_sec  = timeout;
+                }
+
+                while ((ret = select(socket + 1, &rfds, NULL, NULL, timeout ? &tv : NULL)) < 1) {
                     switch (ret) {
                     case 0:
                         LOG(log_debug, logtype_dsi, "select timeout %d s", timeout);
@@ -124,19 +128,21 @@ ssize_t readt(int socket, void *data, const size_t length, int setnonblocking, i
                     default: /* -1 */
                         switch (errno) {
                         case EINTR:
-                            (void)gettimeofday(&now, NULL);
-                            if (now.tv_sec > end.tv_sec
-                                ||
-                                (now.tv_sec == end.tv_sec && now.tv_usec >= end.tv_usec)) {
-                                LOG(log_debug, logtype_afpd, "select timeout %d s", timeout);
-                                goto exit;
-                            }
-                            if (now.tv_usec > end.tv_usec) {
-                                tv.tv_usec = 1000000 + end.tv_usec - now.tv_usec;
-                                tv.tv_sec  = end.tv_sec - now.tv_sec - 1;
-                            } else {
-                                tv.tv_usec = end.tv_usec - now.tv_usec;
-                                tv.tv_sec  = end.tv_sec - now.tv_sec;
+                            if (timeout) {
+                                (void)gettimeofday(&now, NULL);
+                                if (now.tv_sec > end.tv_sec
+                                    ||
+                                    (now.tv_sec == end.tv_sec && now.tv_usec >= end.tv_usec)) {
+                                    LOG(log_debug, logtype_afpd, "select timeout %d s", timeout);
+                                    goto exit;
+                                }
+                                if (now.tv_usec > end.tv_usec) {
+                                    tv.tv_usec = 1000000 + end.tv_usec - now.tv_usec;
+                                    tv.tv_sec  = end.tv_sec - now.tv_sec - 1;
+                                } else {
+                                    tv.tv_usec = end.tv_usec - now.tv_usec;
+                                    tv.tv_sec  = end.tv_sec - now.tv_sec;
+                                }
                             }
                             FD_SET(socket, &rfds);
                             continue;