#include "cbhm_log.h"
#define MIMETYPE_MAX 255
+#define PIPE_RETRY_MAX 2000
typedef struct {
char *mimetype;
{
Cbhm_Received_Data *received_data;
char buffer[255];
- int len, old_len;
+ int len, old_len, retry_cnt = 0;
void *data;
if (!info) return;
if (errno == EINTR || errno == EAGAIN) {
continue;
} else {
- ERR("[CBHM]_cbhm_receive_data: read fail. %m\n");
+ ERR("[CBHM]_cbhm_receive_data: read fail.(%d) %m\n", errno);
_cbhm_free_received_data(received_data);
info->received_data = NULL;
goto receive_data_done;
}
+ } else if (len == 0) {
+ retry_cnt++;
+ if (retry_cnt > PIPE_RETRY_MAX) {
+ ERR("[CBHM] read 0. retry_cnt over %d. break (received:%d)\n", PIPE_RETRY_MAX, received_data->len);
+ break;
+ }
+ continue;
+ }
- } else if (len == 0)
- break;
-
+ retry_cnt = 0;
old_len = received_data->len;
received_data->len += len;
goto receive_data_done;
}
- if (len < 255) break;
+ if (buffer[len - 1] == '\0')
+ break;
}
memcpy(buffer, ((char *)received_data->data) + received_data->len - 1, 1);