comparison 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
comparison
equal deleted inserted replaced
24:f2cce7becf52 25:011cb9337729
111 111
112 /* wait while queue is full */ 112 /* wait while queue is full */
113 while(p_queue->num_avail == 0) { 113 while(p_queue->num_avail == 0) {
114 pthread_cond_timedwait(&p_queue->cond_avail, 114 pthread_cond_timedwait(&p_queue->cond_avail,
115 &p_queue->mutex, &spec); 115 &p_queue->mutex, &spec);
116 if(f_exit) 116 if(f_exit) {
117 pthread_mutex_unlock(&p_queue->mutex);
117 return; 118 return;
119 }
118 } 120 }
119 121
120 p_queue->buffer[p_queue->in] = data; 122 p_queue->buffer[p_queue->in] = data;
121 123
122 /* move position marker for input to next position */ 124 /* move position marker for input to next position */
149 151
150 /* wait while queue is empty */ 152 /* wait while queue is empty */
151 while(p_queue->num_used == 0) { 153 while(p_queue->num_used == 0) {
152 pthread_cond_timedwait(&p_queue->cond_avail, 154 pthread_cond_timedwait(&p_queue->cond_avail,
153 &p_queue->mutex, &spec); 155 &p_queue->mutex, &spec);
154 if(f_exit) 156 if(f_exit) {
157 pthread_mutex_unlock(&p_queue->mutex);
155 return NULL; 158 return NULL;
159 }
156 } 160 }
157 161
158 /* take buffer address */ 162 /* take buffer address */
159 buffer = p_queue->buffer[p_queue->out]; 163 buffer = p_queue->buffer[p_queue->out];
160 164
675 recsec = atoi(recsecstr); 679 recsec = atoi(recsecstr);
676 } 680 }
677 681
678 /* open output file */ 682 /* open output file */
679 char *destfile = argv[optind + 2]; 683 char *destfile = argv[optind + 2];
680 if(!strcmp("-", destfile)) { 684 if(destfile && !strcmp("-", destfile)) {
681 use_stdout = TRUE; 685 use_stdout = TRUE;
682 wfd = 1; /* stdout */ 686 wfd = 1; /* stdout */
683 } 687 }
684 else { 688 else {
685 if(!fileless) { 689 if(!fileless) {