add extra nullptr check in the event loop to handle the case when the finish ptr is set to NULL after it was already scheduled

Wed, 05 Jun 2024 19:50:44 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 05 Jun 2024 19:50:44 +0200
changeset 537
ad44e72fbf50
parent 536
e95fa761db0c
child 538
f9a7b5c76208

add extra nullptr check in the event loop to handle the case when the finish ptr is set to NULL after it was already scheduled

src/server/daemon/event_bsd.c file | annotate | diff | comparison | revisions
src/server/daemon/event_linux.c file | annotate | diff | comparison | revisions
src/server/daemon/event_solaris.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/event_bsd.c	Wed Jun 05 19:49:17 2024 +0200
+++ b/src/server/daemon/event_bsd.c	Wed Jun 05 19:50:44 2024 +0200
@@ -143,7 +143,10 @@
         // call event finish handlers
         for(int i=0;i<numfinished;i++) {
             Event *event = finished[i];
-            finished[i]->finish(ev, event);
+            // check again if the finish callback is set
+            if(finished[i]->finish) {
+                finished[i]->finish(ev, event);
+            }
         }
         // execute return calls
         for(int i=0;i<ev->numret;i++) {
--- a/src/server/daemon/event_linux.c	Wed Jun 05 19:49:17 2024 +0200
+++ b/src/server/daemon/event_linux.c	Wed Jun 05 19:50:44 2024 +0200
@@ -171,7 +171,10 @@
         // call event finish handlers
         for(int i=0;i<numfinished;i++) {
             Event *event = finished[i];
-            finished[i]->finish(ev, event);
+            // check again if the finish callback is set
+            if(finished[i]->finish) {
+                finished[i]->finish(ev, event);
+            }
         }
         // execute return calls
         for(int i=0;i<ev->numret;i++) {
--- a/src/server/daemon/event_solaris.c	Wed Jun 05 19:49:17 2024 +0200
+++ b/src/server/daemon/event_solaris.c	Wed Jun 05 19:50:44 2024 +0200
@@ -124,7 +124,10 @@
         // call event finish handlers
         for(int i=0;i<numfinished;i++) {
             Event *event = finished[i];
-            finished[i]->finish(ev, event);
+            // check again if the finish callback is set
+            if(finished[i]->finish) {
+                finished[i]->finish(ev, event);
+            }
         }
         // execute return calls
         for(int i=0;i<ev->numret;i++) {

mercurial