|
@@ -162,6 +162,12 @@ int main(int argc, const char **argv) {
|
|
|
|
|
|
|
|
nfds_total = 1;
|
|
nfds_total = 1;
|
|
|
|
|
|
|
|
|
|
+ if (unlikely(!(buf = malloc(REQ_SIZE)))) {
|
|
|
|
|
+ vcc_log("*** malloc() failed\n");
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for (;;) {
|
|
for (;;) {
|
|
|
nfds_ready = poll(fds, nfds_total, -1);
|
|
nfds_ready = poll(fds, nfds_total, -1);
|
|
|
|
|
|
|
@@ -202,14 +208,6 @@ int main(int argc, const char **argv) {
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
if (fds[i].revents & POLLIN) {
|
|
if (fds[i].revents & POLLIN) {
|
|
|
- if (!(buf = malloc(REQ_SIZE))) {
|
|
|
|
|
- vcc_log("*** malloc() failed\n");
|
|
|
|
|
-
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- size = read(fds[i].fd, buf, REQ_SIZE);
|
|
|
|
|
-
|
|
|
|
|
if (!size) {
|
|
if (!size) {
|
|
|
vcc_close_connection(fds[i].fd);
|
|
vcc_close_connection(fds[i].fd);
|
|
|
|
|
|
|
@@ -219,9 +217,7 @@ int main(int argc, const char **argv) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- vcc_new_msg(fds[i].fd, buf, size);
|
|
|
|
|
-
|
|
|
|
|
- free(buf);
|
|
|
|
|
|
|
+ vcc_new_msg(fds[i].fd, buf);
|
|
|
|
|
|
|
|
fds[i].events = POLLOUT;
|
|
fds[i].events = POLLOUT;
|
|
|
}
|
|
}
|
|
@@ -236,6 +232,8 @@ int main(int argc, const char **argv) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ free(buf);
|
|
|
|
|
+
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|