mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 11:58:40 +00:00
Bug 6873 - Finish moving from the non-threadsafe (and poor randomness) rand() to threadsafe ast_random()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
6
rtp.c
6
rtp.c
@@ -1008,8 +1008,8 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
|
||||
rtp->them.sin_family = AF_INET;
|
||||
rtp->us.sin_family = AF_INET;
|
||||
rtp->s = rtp_socket();
|
||||
rtp->ssrc = rand();
|
||||
rtp->seqno = rand() & 0xffff;
|
||||
rtp->ssrc = ast_random();
|
||||
rtp->seqno = ast_random() & 0xffff;
|
||||
if (rtp->s < 0) {
|
||||
free(rtp);
|
||||
ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno));
|
||||
@@ -1021,7 +1021,7 @@ struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io
|
||||
}
|
||||
|
||||
/* Select a random port number in the range of possible RTP */
|
||||
x = (rand() % (rtpend-rtpstart)) + rtpstart;
|
||||
x = (ast_random() % (rtpend-rtpstart)) + rtpstart;
|
||||
x = x & ~1;
|
||||
/* Save it for future references. */
|
||||
startplace = x;
|
||||
|
||||
Reference in New Issue
Block a user