[Asterisk-cvs] asterisk asterisk.c,1.19,1.20 autoservice.c,1.2,1.3 channel.c,1.42,1.43 loader.c,1.6,1.7 logger.c,1.3,1.4 manager.c,1.20,1.21 rtp.c,1.26,1.27 sched.c,1.2,1.3

markster at lists.digium.com markster at lists.digium.com
Mon Sep 8 11:46:58 CDT 2003


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv30979

Modified Files:
	asterisk.c autoservice.c channel.c loader.c logger.c manager.c 
	rtp.c sched.c 
Log Message:
BSD portability enhancements (bug #234)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** asterisk.c	5 Sep 2003 04:36:58 -0000	1.19
--- asterisk.c	8 Sep 2003 16:48:06 -0000	1.20
***************
*** 506,510 ****
  }
  
! static pthread_t consolethread = -1;
  
  static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
--- 506,510 ----
  }
  
! static pthread_t consolethread = (pthread_t) -1;
  
  static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
***************
*** 539,543 ****
  	if (complete)
  	/* Wake up a select()ing console */
! 		if (consolethread > -1)
  			pthread_kill(consolethread, SIGURG);
  }
--- 539,543 ----
  	if (complete)
  	/* Wake up a select()ing console */
! 		if (consolethread != (pthread_t) -1)
  			pthread_kill(consolethread, SIGURG);
  }

Index: autoservice.c
===================================================================
RCS file: /usr/cvsroot/asterisk/autoservice.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** autoservice.c	13 Aug 2003 15:25:15 -0000	1.2
--- autoservice.c	8 Sep 2003 16:48:06 -0000	1.3
***************
*** 45,49 ****
  
  static struct asent *aslist = NULL;
! static pthread_t asthread = -1;
  
  static void *autoservice_run(void *ign)
--- 45,49 ----
  
  static struct asent *aslist = NULL;
! static pthread_t asthread = (pthread_t) -1;
  
  static void *autoservice_run(void *ign)
***************
*** 81,85 ****
  		}
  	}
! 	asthread = -1;
  	return NULL;
  }
--- 81,85 ----
  		}
  	}
! 	asthread = (pthread_t) -1;
  	return NULL;
  }
***************
*** 91,95 ****
  	int needstart;
  	ast_mutex_lock(&autolock);
! 	needstart = (asthread == -1) ? 1 : 0 /* aslist ? 0 : 1 */;
  	as = aslist;
  	while(as) {
--- 91,95 ----
  	int needstart;
  	ast_mutex_lock(&autolock);
! 	needstart = (asthread == (pthread_t) -1) ? 1 : 0 /* aslist ? 0 : 1 */;
  	as = aslist;
  	while(as) {
***************
*** 143,147 ****
  			res = 0;
  	}
! 	if (asthread != -1) 
  		pthread_kill(asthread, SIGURG);
  	ast_mutex_unlock(&autolock);
--- 143,147 ----
  			res = 0;
  	}
! 	if (asthread != (pthread_t) -1) 
  		pthread_kill(asthread, SIGURG);
  	ast_mutex_unlock(&autolock);

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** channel.c	28 Aug 2003 20:02:10 -0000	1.42
--- channel.c	8 Sep 2003 16:48:06 -0000	1.43
***************
*** 319,323 ****
  					tmp->fin = 0;
  					tmp->fout = 0;
! 					snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", time(NULL), uniqueint++);
  					headp=&tmp->varshead;
  					ast_mutex_init(&tmp->lock);
--- 319,323 ----
  					tmp->fin = 0;
  					tmp->fout = 0;
! 					snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", (long)time(NULL), uniqueint++);
  					headp=&tmp->varshead;
  					ast_mutex_init(&tmp->lock);
***************
*** 654,658 ****
  		ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
  					"is blocked by thread %ld in procedure %s!  Expect a failure\n",
! 					pthread_self(), chan->name, chan->blocker, chan->blockproc);
  		CRASH;
  	}
--- 654,658 ----
  		ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
  					"is blocked by thread %ld in procedure %s!  Expect a failure\n",
! 					(long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
  		CRASH;
  	}

Index: loader.c
===================================================================
RCS file: /usr/cvsroot/asterisk/loader.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** loader.c	13 Aug 2003 15:25:16 -0000	1.6
--- loader.c	8 Sep 2003 16:48:06 -0000	1.7
***************
*** 171,175 ****
--- 171,177 ----
  	struct module *m;
  	int flags=RTLD_NOW;
+ #ifdef RTLD_GLOBAL
  	char *val;
+ #endif
  	char *key;
  	int o;

Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** logger.c	13 Aug 2003 15:25:16 -0000	1.3
--- logger.c	8 Sep 2003 16:48:06 -0000	1.4
***************
*** 251,255 ****
  			/** Cannot use ast_log() from locked section of ast_log()!
  			    ast_log(LOG_WARNING, "Unable to retrieve local time?\n"); **/
! 			fprintf(stderr, "ast_log: Unable to retrieve local time for %ld?\n", t);
  	} else {
  		if (logfiles) {
--- 251,255 ----
  			/** Cannot use ast_log() from locked section of ast_log()!
  			    ast_log(LOG_WARNING, "Unable to retrieve local time?\n"); **/
! 			fprintf(stderr, "ast_log: Unable to retrieve local time for %ld?\n", (long)t);
  	} else {
  		if (logfiles) {
***************
*** 261,270 ****
  						localtime_r(&t,&tm);
  						strftime(date, sizeof(date), "%b %e %T", &tm);
! 						fprintf(f->f, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], pthread_self(), file, line, function);
  					} else {
  						sprintf(linestr, "%d", line);
  						fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ",
  																term_color(tmp, levels[level], colors[level], 0, sizeof(tmp)),
! 																pthread_self(),
  																term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
  																term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
--- 261,270 ----
  						localtime_r(&t,&tm);
  						strftime(date, sizeof(date), "%b %e %T", &tm);
! 						fprintf(f->f, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], (long)pthread_self(), file, line, function);
  					} else {
  						sprintf(linestr, "%d", line);
  						fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ",
  																term_color(tmp, levels[level], colors[level], 0, sizeof(tmp)),
! 																(long)pthread_self(),
  																term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
  																term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
***************
*** 279,283 ****
  			}
  		} else {
! 			fprintf(stdout, "%s[%ld]: File %s, Line %d (%s): ", levels[level], pthread_self(), file, line, function);
  			va_start(ap, fmt);
  			vfprintf(stdout, fmt, ap);
--- 279,283 ----
  			}
  		} else {
! 			fprintf(stdout, "%s[%ld]: File %s, Line %d (%s): ", levels[level], (long)pthread_self(), file, line, function);
  			va_start(ap, fmt);
  			vfprintf(stdout, fmt, ap);

Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** manager.c	8 Sep 2003 16:44:36 -0000	1.20
--- manager.c	8 Sep 2003 16:48:06 -0000	1.21
***************
*** 727,731 ****
  	for (;;) {
  		sinlen = sizeof(sin);
! 		as = accept(asock, &sin, &sinlen);
  		if (as < 0) {
  			ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
--- 727,731 ----
  	for (;;) {
  		sinlen = sizeof(sin);
! 		as = accept(asock, (struct sockaddr *)&sin, &sinlen);
  		if (as < 0) {
  			ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
***************
*** 922,926 ****
  		}
  		setsockopt(asock, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x));
! 		if (bind(asock, &ba, sizeof(ba))) {
  			ast_log(LOG_WARNING, "Unable to bind socket: %s\n", strerror(errno));
  			close(asock);
--- 922,926 ----
  		}
  		setsockopt(asock, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x));
! 		if (bind(asock, (struct sockaddr *)&ba, sizeof(ba))) {
  			ast_log(LOG_WARNING, "Unable to bind socket: %s\n", strerror(errno));
  			close(asock);

Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** rtp.c	18 Aug 2003 05:31:25 -0000	1.26
--- rtp.c	8 Sep 2003 16:48:06 -0000	1.27
***************
*** 724,729 ****
  		if (rtp->rtcp)
  			rtp->rtcp->us.sin_port = htons(x + 1);
! 		if (!bind(rtp->s, &rtp->us, sizeof(rtp->us)) &&
! 			(!rtp->rtcp || !bind(rtp->rtcp->s, &rtp->rtcp->us, sizeof(rtp->rtcp->us))))
  			break;
  		if (errno != EADDRINUSE) {
--- 724,729 ----
  		if (rtp->rtcp)
  			rtp->rtcp->us.sin_port = htons(x + 1);
! 		if (!bind(rtp->s, (struct sockaddr *)&rtp->us, sizeof(rtp->us)) &&
! 			(!rtp->rtcp || !bind(rtp->rtcp->s, (struct sockaddr *)&rtp->rtcp->us, sizeof(rtp->rtcp->us))))
  			break;
  		if (errno != EADDRINUSE) {
***************
*** 874,878 ****
  	for (x=0;x<4;x++) {
  		if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
! 			res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, &rtp->them, sizeof(rtp->them));
  			if (res <0) 
  				ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
--- 874,878 ----
  	for (x=0;x<4;x++) {
  		if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
! 			res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
  			if (res <0) 
  				ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
***************
*** 961,965 ****
  	rtpheader[2] = htonl(rtp->ssrc); 
  	if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
! 		res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, &rtp->them, sizeof(rtp->them));
  		if (res <0) 
  			ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
--- 961,965 ----
  	rtpheader[2] = htonl(rtp->ssrc); 
  	if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
! 		res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
  		if (res <0) 
  			ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));

Index: sched.c
===================================================================
RCS file: /usr/cvsroot/asterisk/sched.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** sched.c	27 Jul 2003 03:53:19 -0000	1.2
--- sched.c	8 Sep 2003 16:48:06 -0000	1.3
***************
*** 310,315 ****
  				q->callback,
  				q->data,
! 				s,
! 				ms);
  		q=q->next;
  	}
--- 310,315 ----
  				q->callback,
  				q->data,
! 				(long)s,
! 				(long)ms);
  		q=q->next;
  	}




More information about the svn-commits mailing list