1st prize for most insane compiler/execution bug - release

This commit is contained in:
philippe44
2020-02-20 00:39:28 -08:00
parent 1d8fa61d77
commit a1d1e3b148
2 changed files with 28 additions and 6 deletions

View File

@@ -55,7 +55,7 @@ typedef struct raop_ctx_s {
short unsigned port; // RTSP port for AirPlay
int sock; // socket of the above
struct in_addr peer; // IP of the iDevice (airplay sender)
bool running, abort;
bool running;
#ifdef WIN32
pthread_t thread, search_thread;
#else
@@ -63,6 +63,11 @@ typedef struct raop_ctx_s {
StaticTask_t *xTaskBuffer;
StackType_t xStack[RTSP_STACK_SIZE] __attribute__ ((aligned (4)));
#endif
/*
Compiler/Execution bug: if this bool is next to 'running', the rtsp_thread
loop sees 'running' being set to false from at first execution ...
*/
bool abort;
unsigned char mac[6];
int latency;
struct {
@@ -182,7 +187,7 @@ struct raop_ctx_s *raop_create(struct in_addr host, char *name,
#ifdef WIN32
getsockname(ctx->sock, (struct sockaddr *) &addr, &nlen);
ctx->port = ntohs(addr.sin_port);
#endif
#endif
ctx->running = true;
@@ -214,7 +219,7 @@ void raop_delete(struct raop_ctx_s *ctx) {
/*----------------------------------------------------------------------------*/
void raop_delete(struct raop_ctx_s *ctx) {
#ifdef WIN32
#ifdef WIN32
int sock;
struct sockaddr addr;
socklen_t nlen = sizeof(struct sockaddr);
@@ -406,11 +411,15 @@ static void *rtsp_thread(void *arg) {
if (n > 0) res = handle_rtsp(ctx, sock);
if (n < 0 || !res || ctx->abort) {
abort_rtsp(ctx);
abort_rtsp(ctx);
closesocket(sock);
LOG_INFO("RTSP close %u", sock);
sock = -1;
}
}
}
if (sock != -1) closesocket(sock);
#ifndef WIN32
if (!ctx->joiner) {
LOG_ERROR("We shall not be here %u! %x %x", ctx->running);