@@ -260,7 +260,7 @@ rte_mp_action_unregister(const char *name)
260
260
}
261
261
262
262
static int
263
- read_msg (struct mp_msg_internal * m , struct sockaddr_un * s )
263
+ read_msg (int fd , struct mp_msg_internal * m , struct sockaddr_un * s )
264
264
{
265
265
int msglen ;
266
266
struct iovec iov ;
@@ -281,7 +281,7 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
281
281
msgh .msg_controllen = sizeof (control );
282
282
283
283
retry :
284
- msglen = recvmsg (mp_fd , & msgh , 0 );
284
+ msglen = recvmsg (fd , & msgh , 0 );
285
285
286
286
/* zero length message means socket was closed */
287
287
if (msglen == 0 )
@@ -390,11 +390,12 @@ mp_handle(void *arg __rte_unused)
390
390
{
391
391
struct mp_msg_internal msg ;
392
392
struct sockaddr_un sa ;
393
+ int fd ;
393
394
394
- while (mp_fd >= 0 ) {
395
+ while (( fd = __atomic_load_n ( & mp_fd , __ATOMIC_RELAXED )) >= 0 ) {
395
396
int ret ;
396
397
397
- ret = read_msg (& msg , & sa );
398
+ ret = read_msg (fd , & msg , & sa );
398
399
if (ret <= 0 )
399
400
break ;
400
401
@@ -638,9 +639,8 @@ rte_mp_channel_init(void)
638
639
NULL , mp_handle , NULL ) < 0 ) {
639
640
RTE_LOG (ERR , EAL , "failed to create mp thread: %s\n" ,
640
641
strerror (errno ));
641
- close (mp_fd );
642
642
close (dir_fd );
643
- mp_fd = -1 ;
643
+ close ( __atomic_exchange_n ( & mp_fd , -1 , __ATOMIC_RELAXED )) ;
644
644
return -1 ;
645
645
}
646
646
@@ -656,11 +656,10 @@ rte_mp_channel_cleanup(void)
656
656
{
657
657
int fd ;
658
658
659
- if (mp_fd < 0 )
659
+ fd = __atomic_exchange_n (& mp_fd , -1 , __ATOMIC_RELAXED );
660
+ if (fd < 0 )
660
661
return ;
661
662
662
- fd = mp_fd ;
663
- mp_fd = -1 ;
664
663
pthread_cancel (mp_handle_tid );
665
664
pthread_join (mp_handle_tid , NULL );
666
665
close_socket_fd (fd );
0 commit comments