From 0ee517ed0a1daf4b3ef8bf71d49fb350d0d6b4b0 Mon Sep 17 00:00:00 2001 From: fengbojiang Date: Mon, 14 Aug 2023 20:42:34 +0800 Subject: [PATCH] Fiexd some build errors ubuntu 22.04 (kernel:5.19.0-1025, gcc:11.4.0), Ref #777. --- adapter/syscall/Makefile | 4 ++-- adapter/syscall/main_stack_epoll.c | 7 ++++++- adapter/syscall/main_stack_epoll_kernel.c | 7 ++++++- adapter/syscall/main_stack_epoll_thread_socket.c | 9 +++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/adapter/syscall/Makefile b/adapter/syscall/Makefile index 551462ca9..f93e7906e 100644 --- a/adapter/syscall/Makefile +++ b/adapter/syscall/Makefile @@ -90,8 +90,8 @@ libff_syscall.so: ${FF_SYSCALL_OBJS} ${CC} -fPIC -shared -o $@ $^ ${FF_SYSCALL_LIBS} ${DPDK_LIBS} example: - cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -L ${FF_PATH}/adapter/syscall -lff_syscall -o helloworld_stack main_stack.c ${LIBS} - cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -L ${FF_PATH}/adapter/syscall -lff_syscall -o helloworld_stack_thread_socket main_stack_thread_socket.c ${LIBS} + cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -o helloworld_stack main_stack.c -L ${FF_PATH}/adapter/syscall -lff_syscall ${LIBS} + cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -o helloworld_stack_thread_socket main_stack_thread_socket.c -L ${FF_PATH}/adapter/syscall -lff_syscall ${LIBS} cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -o helloworld_stack_epoll main_stack_epoll.c ${LIBS} cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -o helloworld_stack_epoll_thread_socket main_stack_epoll_thread_socket.c ${LIBS} cc ${CFLAGS} -I ${FF_PATH}/adapter/syscall -o helloworld_stack_epoll_kernel main_stack_epoll_kernel.c ${LIBS} diff --git a/adapter/syscall/main_stack_epoll.c b/adapter/syscall/main_stack_epoll.c index a1ae19557..c1f5c1303 100644 --- a/adapter/syscall/main_stack_epoll.c +++ b/adapter/syscall/main_stack_epoll.c @@ -116,7 +116,12 @@ void *loop(void *arg) char buf[256]; size_t readlen = read( events[i].data.fd, buf, sizeof(buf)); if(readlen > 0) { - write( events[i].data.fd, html, sizeof(html) - 1); + ssize_t writelen = write( events[i].data.fd, html, sizeof(html) - 1); + if (writelen < 0){ + printf("write failed, readlen:%lu, writelen:%lu, :%d, %s\n", + readlen, writelen, errno, strerror(errno)); + close(events[i].data.fd); + } } else { epoll_ctl(epfd, EPOLL_CTL_DEL, events[i].data.fd, NULL); close(events[i].data.fd); diff --git a/adapter/syscall/main_stack_epoll_kernel.c b/adapter/syscall/main_stack_epoll_kernel.c index 0557ffe79..9c7d88717 100644 --- a/adapter/syscall/main_stack_epoll_kernel.c +++ b/adapter/syscall/main_stack_epoll_kernel.c @@ -122,7 +122,12 @@ void *loop(void *arg) char buf[256]; size_t readlen = read( events[i].data.fd, buf, sizeof(buf)); if(readlen > 0) { - write( events[i].data.fd, html, sizeof(html) - 1); + size_t writelen = write( events[i].data.fd, html, sizeof(html) - 1); + if (writelen < 0){ + printf("write failed, readlen:%lu, writelen:%lu, :%d, %s\n", + readlen, writelen, errno, strerror(errno)); + close(events[i].data.fd); + } } else { epoll_ctl(epfd, EPOLL_CTL_DEL, events[i].data.fd, NULL); close(events[i].data.fd); diff --git a/adapter/syscall/main_stack_epoll_thread_socket.c b/adapter/syscall/main_stack_epoll_thread_socket.c index f4d6317c0..bb2002fc5 100644 --- a/adapter/syscall/main_stack_epoll_thread_socket.c +++ b/adapter/syscall/main_stack_epoll_thread_socket.c @@ -75,7 +75,7 @@ void *loop(void *arg) thread_id = *(int *)arg; printf("start thread %d\n", thread_id); - + sockfd = socket(AF_INET, SOCK_STREAM | SOCK_FSTACK, 0); printf("thread %d, sockfd:%d\n", thread_id, sockfd); if (sockfd < 0) { @@ -184,7 +184,12 @@ void *loop(void *arg) char buf[256]; size_t readlen = read( events[i].data.fd, buf, sizeof(buf)); if(readlen > 0) { - write( events[i].data.fd, html, sizeof(html) - 1); + size_t writelen = write( events[i].data.fd, html, sizeof(html) - 1); + if (writelen < 0){ + printf("write failed, readlen:%lu, writelen:%lu, :%d, %s\n", + readlen, writelen, errno, strerror(errno)); + close(events[i].data.fd); + } } else { epoll_ctl(epfd, EPOLL_CTL_DEL, events[i].data.fd, NULL); close(events[i].data.fd);