fix kqueue event handler webdav

Thu, 03 Dec 2020 11:24:51 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 03 Dec 2020 11:24:51 +0100
branch
webdav
changeset 263
533f9097d712
parent 262
c459019a3ed3
child 264
81f202caea5b

fix kqueue event handler

src/server/daemon/event_bsd.c file | annotate | diff | comparison | revisions
src/server/safs/service.c file | annotate | diff | comparison | revisions
src/server/webdav/operation.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/event_bsd.c	Sun Nov 01 09:46:57 2020 +0100
+++ b/src/server/daemon/event_bsd.c	Thu Dec 03 11:24:51 2020 +0100
@@ -82,15 +82,32 @@
         numchanges = 0;
         for(int i=0;i<nev;i++) {
             Event *event = (Event*)events[i].udata;
+            if(!event) {
+                log_ereport(LOG_WARN, "Unknown kevent (ident=%d)", (int)events[i].ident);
+                continue;
+            }
+            
             if(event->fn) {
-                int ep = event->events;
-                if(event->fn(ev, event)) {
-                    if(event->events != ep) {
-                        changes[numchanges++].filter = ev_convert2sys_events(ep);
+                u_short kev_flag = 0;
+                int saved_ev = event->events;
+                if(!event->fn(ev, event)) {
+                    // ret 0 => remove event
+                    kev_flag = EV_DELETE;
+                    
+                    if(event->finish) {
+                        event->finish(ev, event);
                     }
-                } else if(event->finish) {
-                    changes[numchanges++].filter = ev_convert2sys_events(ep);
-                    event->finish(ev, event);
+                } else if(saved_ev != event->events) {
+                    // events changed
+                    kev_flag = EV_ADD;
+                    events[i].filter = ev_convert2sys_events(event->events);
+                }
+                
+                if(kev_flag) {
+                    // copy current event to changelist
+                    changes[numchanges] = events[i];
+                    changes[numchanges].flags = kev_flag;
+                    numchanges++;
                 }
             }
         }
--- a/src/server/safs/service.c	Sun Nov 01 09:46:57 2020 +0100
+++ b/src/server/safs/service.c	Thu Dec 03 11:24:51 2020 +0100
@@ -637,7 +637,7 @@
         // send response header
         http_start_response(sn, rq);
         // send content
-        // TODO: fix: send_range_aio is unstable
+        // TODO: fix: send_range_aio is unstable #96
         //ret = send_range_aio(sn, rq, fd, offset, length, NULL, 0);
         //if(ret == REQ_PROCESSING) {
         //    return ret;
--- a/src/server/webdav/operation.c	Sun Nov 01 09:46:57 2020 +0100
+++ b/src/server/webdav/operation.c	Thu Dec 03 11:24:51 2020 +0100
@@ -330,7 +330,7 @@
         req->removecount = remove_count;
         req->userdata = NULL;
         
-        // check if we need to open the file because the backend want's it
+        // check if we need to open the file because the backend wants it
         if(!file && (dav->settings & WS_WEBDAV_PROPPATCH_USE_VFS)
                          == WS_WEBDAV_PROPPATCH_USE_VFS)
         {

mercurial