[Asterisk-Dev] Blocking open(2) does not work with some thread implementations

Thorsten Lockert tholo at sigmasoft.com
Thu Apr 24 14:46:34 MST 2003


Some thread implementations have problems when open(2) blocks --
this changes an open on a named pipe to be non-blocking, and resets
the descriptor to be blocking afterwards.

Index: pbx/pbx_wilcalu.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_wilcalu.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 pbx_wilcalu.c
--- pbx/pbx_wilcalu.c	16 Mar 2003 22:37:31 -0000	1.1.1.2
+++ pbx/pbx_wilcalu.c	24 Apr 2003 21:47:15 -0000
@@ -58,7 +58,9 @@
 {
 	pthread_t dialstring_thread;
 	char * sendbufptr=sendbuf;
-	int fd=open(dialfile,O_RDONLY);
+	int fd=open(dialfile,O_RDONLY|O_NONBLOCK);
+	int flags = fcntl(fd, F_GETFL);
+	fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
 	printf("Entered Wil-Calu fd=%d\n",fd);
 	if(fd<0) {
 		printf("Autodial: Unable to open file\n");
--
Thorsten Lockert      | tholo at sigmasoft.com | Universe, n.:
2121 N. Lakeshore Dr. | tholo at openbsd.org   |         The problem.
Chapel Hill, NC 27514 |                     |



More information about the asterisk-dev mailing list