#include "proto.h"
#define SEND_TIMEOUT 1000 /* milliseconds */
+#define MAX_RETRY_CNT 5
struct recv_info {
int fd;
struct header *hdr;
uint8_t *buf;
struct pollfd fds[1];
+ int retry_cnt = 0;
if (!data || len <= 0 || fd < 0) {
bxt_err("Invalid parameter");
} while (r < 0);
}
- r = send(fd, buf, sizeof(*hdr) + len, MSG_NOSIGNAL);
+ while(retry_cnt < MAX_RETRY_CNT) {
+ r = send(fd, buf, sizeof(*hdr) + len, MSG_NOSIGNAL);
+ if (r == -1) {
+ if (errno == EINTR) {
+ retry_cnt++;
+ continue;
+ }
- free(buf);
+ r = errno;
+ bxt_err("send: fd %d errno %d", fd, r);
+ free(buf);
+
+ if (r == EWOULDBLOCK || r == EAGAIN)
+ return BUXTON_ERROR_TIME_OUT; /* Returns BUXTON_ERROR_TIME_OUT to retry */
- if (r == -1) {
- bxt_err("send: fd %d errno %d", fd, errno);
+ return BUXTON_ERROR_IO_ERROR;
+ }
+ break;
+ }
+
+ free(buf);
+ if(retry_cnt >= MAX_RETRY_CNT) {
+ bxt_err("send: fd %d retry_cnt %d", fd, retry_cnt);
return BUXTON_ERROR_IO_ERROR;
}
_data = g_base64_decode(g_data, &_len);
r = proto_send(cli->fd, MSG_NOTI, (uint8_t *)_data, (int)_len);
+ free(_data);
if (r != BUXTON_ERROR_NONE) {
- bxt_err("send noti again key : %s pid : %d errno : %d",
- (char *)key, cli->cred.pid, errno);
- if (errno == EWOULDBLOCK || errno == EAGAIN) {
- free(_data);
+ bxt_err("send noti again key : %s pid : %d return value : %d",
+ (char *)key, cli->cred.pid, r);
+ if (r == BUXTON_ERROR_TIME_OUT)
return FALSE;
- }
+ } else {
+ _write_file_log(LOG_SEND_DELAYED_NOTI, cli, NULL);
}
- _write_file_log(LOG_SEND_DELAYED_NOTI, cli, NULL);
-
- free(_data);
return TRUE;
}
r = proto_send(cli->fd, req.type, data, len);
if (r != BUXTON_ERROR_NONE) {
bxt_err("send notis: cli pid : %d label : %s key : %s error %d",
- cli->cred.pid, cli->label, rqst->key, errno);
- if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ cli->cred.pid, cli->label, rqst->key, r);
+ if (r == BUXTON_ERROR_TIME_OUT) {
_data = g_base64_encode(data, len);
if (cli->fd_out_id == 0) {