2424// Uncomment to enable more verbose debug printing (in addition to uncommenting POSIX_SOCKET_DEBUG)
2525// #define POSIX_SOCKET_DEEP_DEBUG
2626
27+ #ifdef POSIX_SOCKET_DEBUG
28+ #define DBG_OUT (format , ...) emscripten_errf("[proxy] " format, ##__VA_ARGS__)
29+ #else
30+ #define DBG_OUT (...) do {} while(0)
31+ #endif
32+
33+ #ifdef POSIX_SOCKET_DEEP_DEBUG
34+ #define DEEP_DBG_OUT (format , ...) emscripten_errf("[proxy] " format, ##__VA_ARGS__)
35+ #else
36+ #define DEEP_DBG_OUT (...) do {} while(0)
37+ #endif
38+
2739#define MIN (a ,b ) (((a)<(b))?(a):(b))
2840
2941static void * memdup (const void * ptr , size_t sz ) {
@@ -79,17 +91,13 @@ static PosixSocketCallResult *allocate_call_result(int expectedBytes) {
7991 pthread_mutex_lock (& bridgeLock ); // Guard multithreaded access to 'callResultHead' and 'nextId' below
8092 PosixSocketCallResult * b = (PosixSocketCallResult * )(malloc (sizeof (PosixSocketCallResult )));
8193 if (!b ) {
82- #ifdef POSIX_SOCKET_DEBUG
83- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "allocate_call_result: Failed to allocate call result struct of size %d bytes!\n" , (int )sizeof (PosixSocketCallResult ));
84- #endif
94+ DBG_OUT ("allocate_call_result: Failed to allocate call result struct of size %zu bytes!" , sizeof (PosixSocketCallResult ));
8595 pthread_mutex_unlock (& bridgeLock );
8696 return 0 ;
8797 }
8898 static int nextId = 1 ;
8999 b -> callId = nextId ++ ;
90- #ifdef POSIX_SOCKET_DEEP_DEBUG
91- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "allocate_call_result: allocated call ID %d\n" , b -> callId );
92- #endif
100+ DEEP_DBG_OUT ("allocate_call_result: allocated call ID %d" , b -> callId );
93101 b -> bytes = expectedBytes ;
94102 b -> data = 0 ;
95103 b -> operationCompleted = 0 ;
@@ -107,10 +115,8 @@ static PosixSocketCallResult *allocate_call_result(int expectedBytes) {
107115}
108116
109117static void free_call_result (PosixSocketCallResult * buffer ) {
110- #ifdef POSIX_SOCKET_DEEP_DEBUG
111118 if (buffer )
112- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "free_call_result: freed call ID %d\n" , buffer -> callId );
113- #endif
119+ DEEP_DBG_OUT ("free_call_result: freed call ID %d" , buffer -> callId );
114120
115121 if (buffer -> data ) free (buffer -> data );
116122 free (buffer );
@@ -125,58 +131,48 @@ static PosixSocketCallResult *pop_call_result(int callId) {
125131 if (prev ) prev -> next = b -> next ;
126132 else callResultHead = b -> next ;
127133 b -> next = 0 ;
128- #ifdef POSIX_SOCKET_DEEP_DEBUG
129- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "pop_call_result: Removed call ID %d from pending sockets call queue\n" , callId );
130- #endif
134+ DEEP_DBG_OUT ("pop_call_result: Removed call ID %d from pending sockets call queue" , callId );
131135 pthread_mutex_unlock (& bridgeLock );
132136 return b ;
133137 }
134138 prev = b ;
135139 b = b -> next ;
136140 }
137141 pthread_mutex_unlock (& bridgeLock );
138- #ifdef POSIX_SOCKET_DEBUG
139- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "pop_call_result: No such call ID %d in pending sockets call queue!\n" , callId );
140- #endif
142+ DBG_OUT ("pop_call_result: No such call ID %d in pending sockets call queue!" , callId );
141143 return 0 ;
142144}
143145
144146static void wait_for_call_result (PosixSocketCallResult * b ) {
145- #ifdef POSIX_SOCKET_DEEP_DEBUG
146- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "wait_for_call_result: Waiting for call ID %d\n" , b -> callId );
147- #endif
147+ DEEP_DBG_OUT ("wait_for_call_result: Waiting for call ID %d" , b -> callId );
148148 while (!b -> operationCompleted ) {
149149 emscripten_futex_wait (& b -> operationCompleted , 0 , 1e9 );
150150 }
151- #ifdef POSIX_SOCKET_DEEP_DEBUG
152- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "wait_for_call_result: Waiting for call ID %d done\n" , b -> callId );
153- #endif
151+ DEEP_DBG_OUT ("wait_for_call_result: Waiting for call ID %d done" , b -> callId );
154152}
155153
156154static bool
157155bridge_socket_on_message (int eventType ,
158156 const EmscriptenWebSocketMessageEvent * websocketEvent ,
159157 void * userData ) {
160158 if (websocketEvent -> numBytes < sizeof (SocketCallResultHeader )) {
161- emscripten_log ( EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "Received corrupt WebSocket result message with size %d, not enough space for header, at least %d bytes!\n " , ( int ) websocketEvent -> numBytes , ( int ) sizeof (SocketCallResultHeader ));
159+ emscripten_errf ( "Received corrupt WebSocket result message with size %d, not enough space for header, at least %zu bytes!" , websocketEvent -> numBytes , sizeof (SocketCallResultHeader ));
162160 return true;
163161 }
164162
165163 SocketCallResultHeader * header = (SocketCallResultHeader * )websocketEvent -> data ;
166164
167- #ifdef POSIX_SOCKET_DEEP_DEBUG
168- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "POSIX sockets bridge received message on thread %p, size: %d bytes, for call ID %d\n" , (void * )pthread_self (), websocketEvent -> numBytes , header -> callId );
169- #endif
165+ DEEP_DBG_OUT ("POSIX sockets bridge received message on thread %p, size: %d bytes, for call ID %d" , (void * )pthread_self (), websocketEvent -> numBytes , header -> callId );
170166
171167 PosixSocketCallResult * b = pop_call_result (header -> callId );
172168 if (!b ) {
173- emscripten_log ( EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "Received WebSocket result message to unknown call ID %d!\n " , ( int ) header -> callId );
169+ emscripten_errf ( "Received WebSocket result message to unknown call ID %d!" , header -> callId );
174170 // TODO: Craft a socket result that signifies a failure, and wake the listening thread
175171 return true;
176172 }
177173
178174 if (websocketEvent -> numBytes < b -> bytes ) {
179- emscripten_log ( EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "Received corrupt WebSocket result message with size %d, expected at least %d bytes!\n " , ( int ) websocketEvent -> numBytes , b -> bytes );
175+ emscripten_errf ( "Received corrupt WebSocket result message with size %d, expected at least %d bytes!" , websocketEvent -> numBytes , b -> bytes );
180176 // TODO: Craft a socket result that signifies a failure, and wake the listening thread
181177 return true;
182178 }
@@ -185,12 +181,12 @@ bridge_socket_on_message(int eventType,
185181 b -> data = (SocketCallResultHeader * )memdup (websocketEvent -> data , websocketEvent -> numBytes );
186182
187183 if (!b -> data ) {
188- emscripten_log ( EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "Out of memory, tried to allocate %d bytes!\n " , websocketEvent -> numBytes );
184+ emscripten_errf ( "Out of memory, tried to allocate %d bytes!" , websocketEvent -> numBytes );
189185 return true;
190186 }
191187
192188 if (b -> operationCompleted != 0 ) {
193- emscripten_log ( EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "Memory corruption(?): the received result for completed operation at address %p was expected to be in state 0, but it was at state %d!\n " , & b -> operationCompleted , ( int ) b -> operationCompleted );
189+ emscripten_errf ( "Memory corruption(?): the received result for completed operation at address %p was expected to be in state 0, but it was at state %d!" , & b -> operationCompleted , b -> operationCompleted );
194190 }
195191
196192 b -> operationCompleted = 1 ;
@@ -200,14 +196,10 @@ bridge_socket_on_message(int eventType,
200196}
201197
202198EMSCRIPTEN_WEBSOCKET_T emscripten_init_websocket_to_posix_socket_bridge (const char * bridgeUrl ) {
203- #ifdef POSIX_SOCKET_DEBUG
204- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_JS_STACK , "emscripten_init_websocket_to_posix_socket_bridge(bridgeUrl=\"%s\")\n" , bridgeUrl );
205- #endif
199+ DBG_OUT ("emscripten_init_websocket_to_posix_socket_bridge(bridgeUrl='%s')" , bridgeUrl );
206200 pthread_mutex_lock (& bridgeLock ); // Guard multithreaded access to 'bridgeSocket'
207201 if (bridgeSocket ) {
208- #ifdef POSIX_SOCKET_DEBUG
209- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_WARN | EM_LOG_JS_STACK , "emscripten_init_websocket_to_posix_socket_bridge(bridgeUrl=\"%s\"): A previous bridge socket connection handle existed! Forcibly tearing old connection down.\n" , bridgeUrl );
210- #endif
202+ DBG_OUT ("emscripten_init_websocket_to_posix_socket_bridge(bridgeUrl='%s'): A previous bridge socket connection handle existed! Forcibly tearing old connection down" , bridgeUrl );
211203 emscripten_websocket_close (bridgeSocket , 0 , 0 );
212204 emscripten_websocket_delete (bridgeSocket );
213205 bridgeSocket = 0 ;
@@ -246,9 +238,7 @@ EMSCRIPTEN_WEBSOCKET_T emscripten_init_websocket_to_posix_socket_bridge(const ch
246238#define MAX_OPTIONVALUE_SIZE 16
247239
248240int socket (int domain , int type , int protocol ) {
249- #ifdef POSIX_SOCKET_DEBUG
250- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "socket(domain=%d,type=%d,protocol=%d) on thread %p\n" , domain , type , protocol , (void * )pthread_self ());
251- #endif
241+ DBG_OUT ("socket(domain=%d,type=%d,protocol=%d) on thread %p" , domain , type , protocol , (void * )pthread_self ());
252242
253243 struct {
254244 SocketCallHeader header ;
@@ -273,9 +263,7 @@ int socket(int domain, int type, int protocol) {
273263}
274264
275265int socketpair (int domain , int type , int protocol , int socket_vector [2 ]) {
276- #ifdef POSIX_SOCKET_DEBUG
277- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "socketpair(domain=%d,type=%d,protocol=%d, socket_vector=[%d,%d])\n" , domain , type , protocol , socket_vector [0 ], socket_vector [1 ]);
278- #endif
266+ DBG_OUT ("socketpair(domain=%d,type=%d,protocol=%d, socket_vector=[%d,%d])" , domain , type , protocol , socket_vector [0 ], socket_vector [1 ]);
279267
280268 struct {
281269 SocketCallHeader header ;
@@ -311,9 +299,7 @@ int socketpair(int domain, int type, int protocol, int socket_vector[2]) {
311299}
312300
313301int shutdown (int socket , int how ) {
314- #ifdef POSIX_SOCKET_DEBUG
315- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "shutdown(socket=%d,how=%d)\n" , socket , how );
316- #endif
302+ DBG_OUT ("shutdown(socket=%d,how=%d)" , socket , how );
317303
318304 struct {
319305 SocketCallHeader header ;
@@ -336,9 +322,7 @@ int shutdown(int socket, int how) {
336322}
337323
338324int bind (int socket , const struct sockaddr * address , socklen_t address_len ) {
339- #ifdef POSIX_SOCKET_DEBUG
340- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "bind(socket=%d,address=%p,address_len=%d)\n" , socket , address , address_len );
341- #endif
325+ DBG_OUT ("bind(socket=%d,address=%p,address_len=%d)" , socket , address , address_len );
342326
343327 typedef struct Data {
344328 SocketCallHeader header ;
@@ -368,9 +352,7 @@ int bind(int socket, const struct sockaddr *address, socklen_t address_len) {
368352}
369353
370354int connect (int socket , const struct sockaddr * address , socklen_t address_len ) {
371- #ifdef POSIX_SOCKET_DEBUG
372- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "connect(socket=%d,address=%p,address_len=%d)\n" , socket , address , address_len );
373- #endif
355+ DBG_OUT ("connect(socket=%d,address=%p,address_len=%d)" , socket , address , address_len );
374356
375357 typedef struct Data {
376358 SocketCallHeader header ;
@@ -400,9 +382,7 @@ int connect(int socket, const struct sockaddr *address, socklen_t address_len) {
400382}
401383
402384int listen (int socket , int backlog ) {
403- #ifdef POSIX_SOCKET_DEBUG
404- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "listen(socket=%d,backlog=%d)\n" , socket , backlog );
405- #endif
385+ DBG_OUT ("listen(socket=%d,backlog=%d)" , socket , backlog );
406386
407387 struct {
408388 SocketCallHeader header ;
@@ -432,9 +412,7 @@ int accept4(int socket, struct sockaddr *address, socklen_t *address_len, int fl
432412}
433413
434414int accept (int socket , struct sockaddr * address , socklen_t * address_len ) {
435- #ifdef POSIX_SOCKET_DEBUG
436- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "accept(socket=%d,address=%p,address_len=%p)\n" , socket , address , address_len );
437- #endif
415+ DBG_OUT ("accept(socket=%d,address=%p,address_len=%p)" , socket , address , address_len );
438416
439417 struct {
440418 SocketCallHeader header ;
@@ -471,9 +449,7 @@ int accept(int socket, struct sockaddr *address, socklen_t *address_len) {
471449}
472450
473451int getsockname (int socket , struct sockaddr * address , socklen_t * address_len ) {
474- #ifdef POSIX_SOCKET_DEBUG
475- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "getsockname(socket=%d,address=%p,address_len=%p)\n" , socket , address , address_len );
476- #endif
452+ DBG_OUT ("getsockname(socket=%d,address=%p,address_len=%p)" , socket , address , address_len );
477453
478454 struct {
479455 SocketCallHeader header ;
@@ -510,9 +486,7 @@ int getsockname(int socket, struct sockaddr *address, socklen_t *address_len) {
510486}
511487
512488int getpeername (int socket , struct sockaddr * address , socklen_t * address_len ) {
513- #ifdef POSIX_SOCKET_DEBUG
514- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "getpeername(socket=%d,address=%p,address_len=%p)\n" , socket , address , address_len );
515- #endif
489+ DBG_OUT ("getpeername(socket=%d,address=%p,address_len=%p)" , socket , address , address_len );
516490
517491 struct {
518492 SocketCallHeader header ;
@@ -549,9 +523,7 @@ int getpeername(int socket, struct sockaddr* address, socklen_t* address_len) {
549523}
550524
551525ssize_t send (int socket , const void * message , size_t length , int flags ) {
552- #ifdef POSIX_SOCKET_DEBUG
553- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "send(socket=%d,message=%p,length=%zd,flags=%d)\n" , socket , message , length , flags );
554- #endif
526+ DBG_OUT ("send(socket=%d,message=%p,length=%zd,flags=%d)" , socket , message , length , flags );
555527
556528 typedef struct MSG {
557529 SocketCallHeader header ;
@@ -583,9 +555,7 @@ ssize_t send(int socket, const void *message, size_t length, int flags) {
583555}
584556
585557ssize_t recv (int socket , void * buffer , size_t length , int flags ) {
586- #ifdef POSIX_SOCKET_DEBUG
587- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "recv(socket=%d,buffer=%p,length=%zd,flags=%d)\n" , socket , buffer , length , flags );
588- #endif
558+ DBG_OUT ("recv(socket=%d,buffer=%p,length=%zd,flags=%d)" , socket , buffer , length , flags );
589559
590560 struct {
591561 SocketCallHeader header ;
@@ -625,9 +595,7 @@ ssize_t sendto(int socket,
625595 int flags ,
626596 const struct sockaddr * dest_addr ,
627597 socklen_t dest_len ) {
628- #ifdef POSIX_SOCKET_DEBUG
629- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "sendto(socket=%d,message=%p,length=%zd,flags=%d,dest_addr=%p,dest_len=%d)\n" , socket , message , length , flags , dest_addr , dest_len );
630- #endif
598+ DBG_OUT ("sendto(socket=%d,message=%p,length=%zd,flags=%d,dest_addr=%p,dest_len=%d)" , socket , message , length , flags , dest_addr , dest_len );
631599
632600 typedef struct MSG {
633601 SocketCallHeader header ;
@@ -669,9 +637,7 @@ ssize_t recvfrom(int socket,
669637 int flags ,
670638 struct sockaddr * address ,
671639 socklen_t * address_len ) {
672- #ifdef POSIX_SOCKET_DEBUG
673- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "recvfrom(socket=%d,buffer=%p,length=%zd,flags=%d,address=%p,address_len=%p)\n" , socket , buffer , length , flags , address , address_len );
674- #endif
640+ DBG_OUT ("recvfrom(socket=%d,buffer=%p,length=%zd,flags=%d,address=%p,address_len=%p)" , socket , buffer , length , flags , address , address_len );
675641
676642 struct {
677643 SocketCallHeader header ;
@@ -713,18 +679,14 @@ ssize_t recvfrom(int socket,
713679}
714680
715681ssize_t sendmsg (int socket , const struct msghdr * message , int flags ) {
716- #ifdef POSIX_SOCKET_DEBUG
717- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "sendmsg(socket=%d,message=%p,flags=%d)\n" , socket , message , flags );
718- #endif
682+ DBG_OUT ("sendmsg(socket=%d,message=%p,flags=%d)" , socket , message , flags );
719683
720684 abort (); // TODO
721685 return 0 ;
722686}
723687
724688ssize_t recvmsg (int socket , struct msghdr * message , int flags ) {
725- #ifdef POSIX_SOCKET_DEBUG
726- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "recvmsg(socket=%d,message=%p,flags=%d)\n" , socket , message , flags );
727- #endif
689+ DBG_OUT ("recvmsg(socket=%d,message=%p,flags=%d)" , socket , message , flags );
728690
729691 abort (); // TODO
730692 return 0 ;
@@ -735,9 +697,7 @@ int getsockopt(int socket,
735697 int option_name ,
736698 void * option_value ,
737699 socklen_t * option_len ) {
738- #ifdef POSIX_SOCKET_DEBUG
739- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "getsockopt(socket=%d,level=%d,option_name=%d,option_value=%p,option_len=%p)\n" , socket , level , option_name , option_value , option_len );
740- #endif
700+ DBG_OUT ("getsockopt(socket=%d,level=%d,option_name=%d,option_value=%p,option_len=%p)" , socket , level , option_name , option_value , option_len );
741701
742702 struct {
743703 SocketCallHeader header ;
@@ -780,9 +740,7 @@ int setsockopt(int socket,
780740 int option_name ,
781741 const void * option_value ,
782742 socklen_t option_len ) {
783- #ifdef POSIX_SOCKET_DEBUG
784- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "setsockopt(socket=%d,level=%d,option_name=%d,option_value=%p,option_len=%d)\n" , socket , level , option_name , option_value , option_len );
785- #endif
743+ DBG_OUT ("setsockopt(socket=%d,level=%d,option_name=%d,option_value=%p,option_len=%d)" , socket , level , option_name , option_value , option_len );
786744
787745 typedef struct MSG {
788746 SocketCallHeader header ;
@@ -871,25 +829,19 @@ int getaddrinfo(const char* node,
871829 d .ai_protocol = hints -> ai_protocol ;
872830 }
873831
874- #ifdef POSIX_SOCKET_DEBUG
875- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "getaddrinfo(node=%s,service=%s,hasHints=%d,ai_flags=%d,ai_family=%d,ai_socktype=%d,ai_protocol=%d,hintsPtr=%p,resPtr=%p)\n" , node , service , d .hasHints , d .ai_flags , d .ai_family , d .ai_socktype , d .ai_protocol , hints , res );
876- #endif
832+ DBG_OUT ("getaddrinfo(node=%s,service=%s,hasHints=%d,ai_flags=%d,ai_family=%d,ai_socktype=%d,ai_protocol=%d,hintsPtr=%p,resPtr=%p)" , node , service , d .hasHints , d .ai_flags , d .ai_family , d .ai_socktype , d .ai_protocol , hints , res );
877833
878834 emscripten_websocket_send_binary (bridgeSocket , & d , sizeof (d ));
879835
880836 wait_for_call_result (b );
881837 int ret = b -> data -> ret ;
882- #ifdef POSIX_SOCKET_DEBUG
883- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "getaddrinfo finished, ret=%d\n" , ret );
884- #endif
838+ DBG_OUT ("getaddrinfo finished, ret=%d" , ret );
885839 if (ret == 0 ) {
886840 if (res ) {
887841 Result * r = (Result * )b -> data ;
888842 uint8_t * raiAddr = (uint8_t * )& r -> addr [0 ];
889843 struct addrinfo * results = (struct addrinfo * )malloc (sizeof (struct addrinfo )* r -> addrCount );
890- #ifdef POSIX_SOCKET_DEBUG
891- emscripten_log (EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK , "%d results\n" , r -> addrCount );
892- #endif
844+ DBG_OUT ("%d results" , r -> addrCount );
893845 for (size_t i = 0 ; i < r -> addrCount ; ++ i ) {
894846 ResAddrinfo * rai = (ResAddrinfo * )raiAddr ;
895847 results [i ].ai_flags = rai -> ai_flags ;
0 commit comments