Skip to content

Commit e69f80e

Browse files
committed
http/sdp: remove static var
1 parent 2fbc075 commit e69f80e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/utils/sdp.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct sdp {
125125
char sdp_receiver[1024];
126126
char sdp_filename[MAX_PATH_SIZE];
127127
bool server_started;
128+
uint16_t portInHostOrder;
128129
};
129130

130131
static bool gen_sdp(struct sdp *sdp_state);
@@ -452,8 +453,6 @@ struct Response* createResponseForRequest(const struct Request* request, struct
452453
return response;
453454
}
454455

455-
static uint16_t portInHostOrder;
456-
457456
static THREAD_RETURN_TYPE STDCALL_ON_WIN32 acceptConnectionsThread(void* param) {
458457
struct sockaddr_storage ss = { 0 };
459458
struct sdp *sdp = ((struct Server *) param)->tag;
@@ -462,11 +461,11 @@ static THREAD_RETURN_TYPE STDCALL_ON_WIN32 acceptConnectionsThread(void* param)
462461
if (sdp->ip_version == 4) {
463462
struct sockaddr_in *sin = (struct sockaddr_in *) &ss;
464463
sin->sin_addr.s_addr = htonl(INADDR_ANY);
465-
sin->sin_port = htons(portInHostOrder);
464+
sin->sin_port = htons(sdp->portInHostOrder);
466465
} else {
467466
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &ss;
468467
sin6->sin6_addr = in6addr_any;
469-
sin6->sin6_port = htons(portInHostOrder);
468+
sin6->sin6_port = htons(sdp->portInHostOrder);
470469
}
471470
acceptConnectionsUntilStopped(param, (struct sockaddr *) &ss, sa_len);
472471
MSG(VERBOSE, "Warning: HTTP/SDP thread has exited.\n");
@@ -531,7 +530,7 @@ static void print_http_path(struct sdp *sdp) {
531530
"%s can play SDP with URL "
532531
"http://%s%s%s:%u/%s\n",
533532
recv_str, ipv6 ? "[" : "", hostname, ipv6 ? "]" : "",
534-
portInHostOrder, SDP_FILE);
533+
sdp->portInHostOrder, SDP_FILE);
535534
}
536535
}
537536
}
@@ -546,7 +545,7 @@ static bool sdp_run_http_server(struct sdp *sdp)
546545
assert(port >= 0 && port < 65536);
547546
assert(sdp->sdp_dump != NULL);
548547

549-
portInHostOrder = port;
548+
sdp->portInHostOrder = port;
550549
sdp->http_server.tag = sdp;
551550
pthread_create(&sdp->http_server_thr, NULL, &acceptConnectionsThread, &sdp->http_server);
552551
// some resource will definitely leak but it shouldn't be a problem

0 commit comments

Comments
 (0)