29
29
30
30
#include <trusty/ipc.h>
31
31
32
- int tipc_connect (const char * dev_name , const char * srv_name )
33
- {
34
- int fd ;
35
- int rc ;
32
+ int tipc_connect (const char * dev_name , const char * srv_name ) {
33
+ int fd ;
34
+ int rc ;
36
35
37
- fd = open (dev_name , O_RDWR );
38
- if (fd < 0 ) {
39
- rc = - errno ;
40
- ALOGE ("%s: cannot open tipc device \"%s\": %s\n" ,
41
- __func__ , dev_name , strerror (errno ));
42
- return rc < 0 ? rc : -1 ;
43
- }
36
+ fd = TEMP_FAILURE_RETRY (open (dev_name , O_RDWR ));
37
+ if (fd < 0 ) {
38
+ rc = - errno ;
39
+ ALOGE ("%s: cannot open tipc device \"%s\": %s\n" , __func__ , dev_name , strerror (errno ));
40
+ return rc < 0 ? rc : -1 ;
41
+ }
44
42
45
- rc = ioctl (fd , TIPC_IOC_CONNECT , srv_name );
46
- if (rc < 0 ) {
47
- rc = - errno ;
48
- ALOGE ("%s: can't connect to tipc service \"%s\" (err=%d)\n" ,
49
- __func__ , srv_name , errno );
50
- close (fd );
51
- return rc < 0 ? rc : -1 ;
52
- }
43
+ rc = TEMP_FAILURE_RETRY (ioctl (fd , TIPC_IOC_CONNECT , srv_name ));
44
+ if (rc < 0 ) {
45
+ rc = - errno ;
46
+ ALOGE ("%s: can't connect to tipc service \"%s\" (err=%d)\n" , __func__ , srv_name , errno );
47
+ close (fd );
48
+ return rc < 0 ? rc : -1 ;
49
+ }
53
50
54
- ALOGV ("%s: connected to \"%s\" fd %d\n" , __func__ , srv_name , fd );
55
- return fd ;
51
+ ALOGV ("%s: connected to \"%s\" fd %d\n" , __func__ , srv_name , fd );
52
+ return fd ;
56
53
}
57
54
58
55
ssize_t tipc_send (int fd , const struct iovec * iov , int iovcnt , struct trusty_shm * shms ,
@@ -63,15 +60,14 @@ ssize_t tipc_send(int fd, const struct iovec* iov, int iovcnt, struct trusty_shm
63
60
req .shm = (__u64 )shms ;
64
61
req .shm_cnt = (__u64 )shmcnt ;
65
62
66
- int rc = ioctl (fd , TIPC_IOC_SEND_MSG , & req );
63
+ int rc = TEMP_FAILURE_RETRY ( ioctl (fd , TIPC_IOC_SEND_MSG , & req ) );
67
64
if (rc < 0 ) {
68
65
ALOGE ("%s: failed to send message (err=%d)\n" , __func__ , rc );
69
66
}
70
67
71
68
return rc ;
72
69
}
73
70
74
- void tipc_close (int fd )
75
- {
76
- close (fd );
71
+ void tipc_close (int fd ) {
72
+ close (fd );
77
73
}
0 commit comments