Skip to content

Commit f6bf01a

Browse files
committed
signals: fix build and runtime issues when signals all isabled
Fix build and runtime issues when signals all disabled. Signed-off-by: Chengdong Wang <[email protected]>
1 parent 60d814e commit f6bf01a

File tree

18 files changed

+164
-40
lines changed

18 files changed

+164
-40
lines changed

canutils/candump/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config CANUTILS_CANDUMP
77
tristate "SocketCAN candump tool"
88
default n
9-
depends on NET_CAN && CANUTILS_LIBCANUTILS
9+
depends on NET_CAN && CANUTILS_LIBCANUTILS && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the SocketCAN candump tool ported from
1212
https://github.com/linux-can/can-utils

examples/chrono/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_CHRONO
77
tristate "Chronometer example to use with STM32LDiscover"
88
default n
9-
depends on SLCD
9+
depends on SLCD && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the Chronometer example
1212

examples/djoystick/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_DJOYSTICK
77
tristate "Discrete joystick example"
88
default n
9-
depends on INPUT_DJOYSTICK
9+
depends on INPUT_DJOYSTICK && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the discrete joystick example
1212

examples/i2sloop/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
config EXAMPLES_I2SLOOP
77
tristate "I2S loopback test"
88
default n
9-
depends on I2S && AUDIO && DRIVERS_AUDIO && AUDIO_I2SCHAR
9+
depends on I2S && AUDIO && DRIVERS_AUDIO && AUDIO_I2SCHAR && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the I2S loopback test

examples/ipforward/ipforward.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,16 @@ static FAR void *ipfwd_receiver(FAR void *arg)
542542
int errcode;
543543
int i;
544544

545+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
546+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
547+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
548+
#endif
549+
545550
for (i = 0; i < IPFWD_NPACKETS; i++)
546551
{
552+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
553+
pthread_testcancel();
554+
#endif
547555
nread = read(fwd->ia_fd, fwd->ia_buffer, IPFWD_BUFSIZE);
548556
if (nread < 0)
549557
{
@@ -840,7 +848,12 @@ int main(int argc, FAR char *argv[])
840848

841849
/* Wait for receiver thread to terminate */
842850

851+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
852+
pthread_cancel(fwd.if_receiver);
853+
#else
843854
pthread_kill(fwd.if_receiver, 9);
855+
#endif
856+
844857
ret = pthread_join(fwd.if_receiver, &value);
845858
if (ret != OK)
846859
{

examples/oneshot/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_ONESHOT
77
tristate "Oneshot timer example"
88
default n
9-
depends on ONESHOT
9+
depends on ONESHOT && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the oneshot timer driver example
1212

examples/shv-nxboot-updater/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
menuconfig EXAMPLES_SHV_NXBOOT_UPDATER
77
bool "Silicon Heaven Firmware updates for NXBoot"
8-
depends on NETUTILS_LIBSHVC
8+
depends on NETUTILS_LIBSHVC && ENABLE_ALL_SIGNALS
99
default n
1010
---help---
1111
Enable the shv-nxboot-updater application.

examples/usrsocktest/usrsocktest_wake_with_signal.c

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,20 @@ static void do_usrsock_blocking_socket_thread(FAR void *param)
146146
TEST_ASSERT_TRUE(test_hang);
147147
TEST_ASSERT_TRUE(test_abort);
148148

149+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
150+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
151+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
152+
#endif
153+
149154
/* Allow main thread to hang usrsock daemon at this point. */
150155

151156
sem_post(&tid_startsem);
152157
sem_wait(&tid_releasesem);
153158

159+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
160+
pthread_testcancel();
161+
#endif
162+
154163
/* Attempt hanging open socket. */
155164

156165
sem_post(&tid_startsem);
@@ -176,6 +185,11 @@ static void do_usrsock_blocking_close_thread(FAR void *param)
176185
TEST_ASSERT_TRUE(test_hang);
177186
TEST_ASSERT_TRUE(test_abort);
178187

188+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
189+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
190+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
191+
#endif
192+
179193
/* Open socket. */
180194

181195
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -190,6 +204,10 @@ static void do_usrsock_blocking_close_thread(FAR void *param)
190204
sem_post(&tid_startsem);
191205
sem_wait(&tid_releasesem);
192206

207+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
208+
pthread_testcancel();
209+
#endif
210+
193211
/* Attempt hanging close socket. */
194212

195213
sem_post(&tid_startsem);
@@ -214,6 +232,11 @@ static void do_usrsock_blocking_connect_thread(FAR void *param)
214232

215233
TEST_ASSERT_TRUE(test_hang || !test_hang);
216234

235+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
236+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
237+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
238+
#endif
239+
217240
/* Open socket. */
218241

219242
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -228,6 +251,10 @@ static void do_usrsock_blocking_connect_thread(FAR void *param)
228251
sem_post(&tid_startsem);
229252
sem_wait(&tid_releasesem);
230253

254+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
255+
pthread_testcancel();
256+
#endif
257+
231258
/* Attempt blocking connect. */
232259

233260
sem_post(&tid_startsem);
@@ -257,6 +284,11 @@ static void do_usrsock_blocking_setsockopt_thread(FAR void *param)
257284
bool test_abort = !!(test_flags & TEST_FLAG_DAEMON_ABORT);
258285
bool test_hang = !!(test_flags & TEST_FLAG_PAUSE_USRSOCK_HANDLING);
259286

287+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
288+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
289+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
290+
#endif
291+
260292
/* Open socket. */
261293

262294
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -274,6 +306,10 @@ static void do_usrsock_blocking_setsockopt_thread(FAR void *param)
274306
sem_post(&tid_startsem);
275307
sem_wait(&tid_releasesem);
276308

309+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
310+
pthread_testcancel();
311+
#endif
312+
277313
/* Attempt hanging setsockopt. */
278314

279315
sem_post(&tid_startsem);
@@ -304,6 +340,11 @@ static void do_usrsock_blocking_getsockopt_thread(FAR void *param)
304340
bool test_abort = !!(test_flags & TEST_FLAG_DAEMON_ABORT);
305341
bool test_hang = !!(test_flags & TEST_FLAG_PAUSE_USRSOCK_HANDLING);
306342

343+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
344+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
345+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
346+
#endif
347+
307348
/* Open socket. */
308349

309350
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -321,6 +362,10 @@ static void do_usrsock_blocking_getsockopt_thread(FAR void *param)
321362
sem_post(&tid_startsem);
322363
sem_wait(&tid_releasesem);
323364

365+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
366+
pthread_testcancel();
367+
#endif
368+
324369
/* Attempt hanging getsockopt. */
325370

326371
sem_post(&tid_startsem);
@@ -352,6 +397,11 @@ static void do_usrsock_blocking_send_thread(FAR void *param)
352397

353398
TEST_ASSERT_TRUE(test_hang || !test_hang);
354399

400+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
401+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
402+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
403+
#endif
404+
355405
/* Open socket. */
356406

357407
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -372,6 +422,10 @@ static void do_usrsock_blocking_send_thread(FAR void *param)
372422
sem_post(&tid_startsem);
373423
sem_wait(&tid_releasesem);
374424

425+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
426+
pthread_testcancel();
427+
#endif
428+
375429
/* Attempt blocking send. */
376430

377431
sem_post(&tid_startsem);
@@ -401,6 +455,11 @@ static void do_usrsock_blocking_recv_thread(FAR void *param)
401455

402456
TEST_ASSERT_TRUE(test_hang || !test_hang);
403457

458+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
459+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
460+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
461+
#endif
462+
404463
/* Open socket. */
405464

406465
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -421,6 +480,10 @@ static void do_usrsock_blocking_recv_thread(FAR void *param)
421480
sem_post(&tid_startsem);
422481
sem_wait(&tid_releasesem);
423482

483+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
484+
pthread_testcancel();
485+
#endif
486+
424487
/* Attempt blocking recv. */
425488

426489
sem_post(&tid_startsem);
@@ -454,6 +517,11 @@ static void do_usrsock_blocking_poll_thread(FAR void *param)
454517
TEST_ASSERT_TRUE(test_abort);
455518
TEST_ASSERT_TRUE(test_hang || !test_hang);
456519

520+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
521+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
522+
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
523+
#endif
524+
457525
/* Open socket. */
458526

459527
test_sd[tidx] = socket(AF_INET, SOCK_STREAM, 0);
@@ -474,6 +542,10 @@ static void do_usrsock_blocking_poll_thread(FAR void *param)
474542
sem_post(&tid_startsem);
475543
sem_wait(&tid_releasesem);
476544

545+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
546+
pthread_testcancel();
547+
#endif
548+
477549
/* Attempt poll. */
478550

479551
pfd.fd = test_sd[tidx];
@@ -560,8 +632,11 @@ static void do_wake_test(enum e_test_type type, int flags)
560632

561633
for (tidx = 0; tidx < nthreads; tidx++)
562634
{
635+
#ifdef CONFIG_DISABLE_ALL_SIGNALS
636+
pthread_cancel(tid[tidx]);
637+
#else
563638
pthread_kill(tid[tidx], SIGUSR1);
564-
639+
#endif
565640
/* Wait threads to complete work. */
566641

567642
ret = pthread_join(tid[tidx], NULL);

examples/xedge_demo/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
config EXAMPLES_XEDGE_DEMO
77
tristate "Xedge IoT Toolkit Demo"
8-
depends on NETUTILS_XEDGE && ALLOW_GPL_COMPONENTS
8+
depends on NETUTILS_XEDGE && ALLOW_GPL_COMPONENTS && ENABLE_ALL_SIGNALS
99
default n
1010
---help---
1111
Simple demonstration of the Xedge IoT Toolkit library.
12-
12+
1313
This example shows how to integrate and use the Xedge library
1414
in your NuttX application. Xedge provides a high-level development
1515
environment for creating IoT and industrial device applications

examples/zerocross/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_ZEROCROSS
77
tristate "Zero Cross Detection example"
88
default n
9-
depends on SENSORS_ZEROCROSS
9+
depends on SENSORS_ZEROCROSS && ENABLE_ALL_SIGNALS
1010
---help---
1111
Enable the zero cross detection example
1212

0 commit comments

Comments
 (0)