diff mbox series

[5/5] network_thread DEBUG_IPC: move off the msglock section

Message ID 20240705065434.3608030-6-dominique.martinet@atmark-techno.com
State Changes Requested
Headers show
Series misc fixes | expand

Commit Message

Dominique Martinet July 5, 2024, 6:54 a.m. UTC
logging something can call into network_notifier() through notify(),
which will dead lock on msglock if logging while that lock is held

That probably isn't used by anyone so we could just remove it,
but if we're keeping it it should at least work...

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
That log wasn't even very useful to me -- I'd suggest removing the two
small ifdef DEBUG_IPC sections instead if you prefer.

 core/network_thread.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Stefano Babic July 5, 2024, 12:15 p.m. UTC | #1
Hi Dominique,

On 05.07.24 08:54, Dominique Martinet wrote:
> logging something can call into network_notifier() through notify(),
> which will dead lock on msglock if logging while that lock is held
>
> That probably isn't used by anyone so we could just remove it,
> but if we're keeping it it should at least work...
>
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
> ---
> That log wasn't even very useful to me -- I'd suggest removing the two
> small ifdef DEBUG_IPC sections instead if you prefer.

I used this #ifdef just at the beginning and inside this module, and it
is neither helpful nor used. DEBUG_IPC is never set. Yes, I strongly
prefer to remove it, it just a remain from my first implementation.

Best regards,
Stefano

>
>   core/network_thread.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/core/network_thread.c b/core/network_thread.c
> index d7b713fb2154..f664b267d4c5 100644
> --- a/core/network_thread.c
> +++ b/core/network_thread.c
> @@ -513,13 +513,14 @@ void *network_thread (void *data)
>   					nrmsgs--;
>   					strncpy(msg.data.status.desc, notification->msg,
>   						sizeof(msg.data.status.desc) - 1);
> -#ifdef DEBUG_IPC
> -					DEBUG("GET STATUS: %s\n", msg.data.status.desc);
> -#endif
>   					msg.data.status.current = notification->status;
>   					msg.data.status.error = notification->error;
>   				}
>   				pthread_mutex_unlock(&msglock);
> +#ifdef DEBUG_IPC
> +				if (notification)
> +					DEBUG("GET STATUS: %s\n", msg.data.status.desc);
> +#endif
>
>   				break;
>   			case NOTIFY_STREAM:
diff mbox series

Patch

diff --git a/core/network_thread.c b/core/network_thread.c
index d7b713fb2154..f664b267d4c5 100644
--- a/core/network_thread.c
+++ b/core/network_thread.c
@@ -513,13 +513,14 @@  void *network_thread (void *data)
 					nrmsgs--;
 					strncpy(msg.data.status.desc, notification->msg,
 						sizeof(msg.data.status.desc) - 1);
-#ifdef DEBUG_IPC
-					DEBUG("GET STATUS: %s\n", msg.data.status.desc);
-#endif
 					msg.data.status.current = notification->status;
 					msg.data.status.error = notification->error;
 				}
 				pthread_mutex_unlock(&msglock);
+#ifdef DEBUG_IPC
+				if (notification)
+					DEBUG("GET STATUS: %s\n", msg.data.status.desc);
+#endif
 
 				break;
 			case NOTIFY_STREAM: