diff recpt1/recpt1.c @ 25:011cb9337729

- avoid broken lock on exit - fixed a bug that it crashed on udp fileless broadcast
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 27 Feb 2009 22:49:41 +0900
parents f2cce7becf52
children c6264c15f39d
line wrap: on
line diff
--- a/recpt1/recpt1.c	Fri Feb 27 22:17:39 2009 +0900
+++ b/recpt1/recpt1.c	Fri Feb 27 22:49:41 2009 +0900
@@ -113,8 +113,10 @@
     while(p_queue->num_avail == 0) {
         pthread_cond_timedwait(&p_queue->cond_avail,
                                &p_queue->mutex, &spec);
-        if(f_exit)
+        if(f_exit) {
+            pthread_mutex_unlock(&p_queue->mutex);
             return;
+        }
     }
 
     p_queue->buffer[p_queue->in] = data;
@@ -151,8 +153,10 @@
     while(p_queue->num_used == 0) {
         pthread_cond_timedwait(&p_queue->cond_avail,
                                &p_queue->mutex, &spec);
-        if(f_exit)
+        if(f_exit) {
+            pthread_mutex_unlock(&p_queue->mutex);
             return NULL;
+        }
     }
 
     /* take buffer address */
@@ -677,7 +681,7 @@
 
     /* open output file */
     char *destfile = argv[optind + 2];
-	if(!strcmp("-", destfile)) {
+	if(destfile && !strcmp("-", destfile)) {
         use_stdout = TRUE;
         wfd = 1; /* stdout */
 	}