diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-27 08:17:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-27 08:17:55 +0000 |
commit | df2132e55bb03881ea4502ecdc2170a37f14b3b5 (patch) | |
tree | 7300fc6b0904d9cf99d7565c093beeb1b4e159cf /src/util/os_priority.c | |
parent | 8d7a8374f8d3fbd0c58eeb9ef87d5bf328cba751 (diff) | |
download | gnunet-df2132e55bb03881ea4502ecdc2170a37f14b3b5.tar.gz gnunet-df2132e55bb03881ea4502ecdc2170a37f14b3b5.zip |
fix potential NPE on shutdown
Diffstat (limited to 'src/util/os_priority.c')
-rw-r--r-- | src/util/os_priority.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 2a6ea8321..9b1ec0963 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -70,6 +70,11 @@ static struct GNUNET_OS_Process current_process; | |||
70 | */ | 70 | */ |
71 | static struct GNUNET_SCHEDULER_Task *pch; | 71 | static struct GNUNET_SCHEDULER_Task *pch; |
72 | 72 | ||
73 | /** | ||
74 | * Handle for the #shutdown_pch() Task. | ||
75 | */ | ||
76 | static struct GNUNET_SCHEDULER_Task *spch; | ||
77 | |||
73 | 78 | ||
74 | /** | 79 | /** |
75 | * This handler is called on shutdown to remove the #pch. | 80 | * This handler is called on shutdown to remove the #pch. |
@@ -80,7 +85,7 @@ static void | |||
80 | shutdown_pch (void *cls) | 85 | shutdown_pch (void *cls) |
81 | { | 86 | { |
82 | struct GNUNET_DISK_FileHandle *control_pipe = cls; | 87 | struct GNUNET_DISK_FileHandle *control_pipe = cls; |
83 | 88 | ||
84 | GNUNET_SCHEDULER_cancel (pch); | 89 | GNUNET_SCHEDULER_cancel (pch); |
85 | pch = NULL; | 90 | pch = NULL; |
86 | GNUNET_DISK_file_close (control_pipe); | 91 | GNUNET_DISK_file_close (control_pipe); |
@@ -114,6 +119,8 @@ parent_control_handler (void *cls) | |||
114 | "Closing control pipe\n"); | 119 | "Closing control pipe\n"); |
115 | GNUNET_DISK_file_close (control_pipe); | 120 | GNUNET_DISK_file_close (control_pipe); |
116 | control_pipe = NULL; | 121 | control_pipe = NULL; |
122 | GNUNET_SCHEDULER_cancel (spch); | ||
123 | spch = NULL; | ||
117 | return; | 124 | return; |
118 | } | 125 | } |
119 | pipe_fd = getenv (GNUNET_OS_CONTROL_PIPE); | 126 | pipe_fd = getenv (GNUNET_OS_CONTROL_PIPE); |
@@ -205,8 +212,8 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
205 | control_pipe, | 212 | control_pipe, |
206 | &parent_control_handler, | 213 | &parent_control_handler, |
207 | control_pipe); | 214 | control_pipe); |
208 | GNUNET_SCHEDULER_add_shutdown (&shutdown_pch, | 215 | spch = GNUNET_SCHEDULER_add_shutdown (&shutdown_pch, |
209 | control_pipe); | 216 | control_pipe); |
210 | putenv (GNUNET_OS_CONTROL_PIPE "="); | 217 | putenv (GNUNET_OS_CONTROL_PIPE "="); |
211 | } | 218 | } |
212 | 219 | ||
@@ -1858,7 +1865,7 @@ cmd_read (void *cls) | |||
1858 | cmd->off -= (end + 1 - cmd->buf); | 1865 | cmd->off -= (end + 1 - cmd->buf); |
1859 | end = memchr (cmd->buf, '\n', cmd->off); | 1866 | end = memchr (cmd->buf, '\n', cmd->off); |
1860 | } | 1867 | } |
1861 | cmd->rtask | 1868 | cmd->rtask |
1862 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining | 1869 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining |
1863 | (cmd->timeout), | 1870 | (cmd->timeout), |
1864 | cmd->r, | 1871 | cmd->r, |