summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <sylixos@gmail.com>2019-05-09 14:35:22 (GMT)
committer Hanhui <sylixos@gmail.com>2019-04-18 15:50:21 (GMT)
commit914dfdd538c3a6a3b3516771fd6bb50d23455951 (patch)
treeb394b11027019ab09a6ffc21d354c17258f7510e
parent1429da87afdc2fdf9bad37c4888368f1593dc515 (diff)
downloadAIC-OS-914dfdd538c3a6a3b3516771fd6bb50d23455951.zip
Add TCP_DESC support.
-rw-r--r--SylixOS/include/netinet/tcp.h41
-rw-r--r--SylixOS/include/network/lwip/sockets.h3
-rw-r--r--SylixOS/loader/include/loader_vppatch.h4
-rw-r--r--SylixOS/loader/src/loader_vppatch.c1
-rw-r--r--SylixOS/loader/src/loader_wait.c8
-rw-r--r--SylixOS/net/lwip/src/api/sockets.c40
-rw-r--r--SylixOS/posix/aio/aio_lib.c8
7 files changed, 101 insertions, 4 deletions
diff --git a/SylixOS/include/netinet/tcp.h b/SylixOS/include/netinet/tcp.h
index afa2232..91bc32e 100644
--- a/SylixOS/include/netinet/tcp.h
+++ b/SylixOS/include/netinet/tcp.h
@@ -64,6 +64,47 @@ struct tcphdr {
u_short th_urp; /* urgent pointer */
} __packed;
+/*********************************************************************************************************
+ TCP describe.
+*********************************************************************************************************/
+
+#define TCP_STATE_CLOSED 0
+#define TCP_STATE_LISTEN 1
+#define TCP_STATE_SYN_SENT 2
+#define TCP_STATE_SYN_RCVD 3
+#define TCP_STATE_ESTABLISHED 4
+#define TCP_STATE_FIN_WAIT_1 5
+#define TCP_STATE_FIN_WAIT_2 6
+#define TCP_STATE_CLOSE_WAIT 7
+#define TCP_STATE_CLOSING 8
+#define TCP_STATE_LAST_ACK 9
+#define TCP_STATE_TIME_WAIT 10
+
+struct tcp_desc {
+ u_char tcp_state;
+ u_char tcp_backlog;
+ u_char tcp_accpend;
+ u_char tcp_rcv_scale;
+ u_char tcp_snd_scale;
+ u_char tcp_pad1[3];
+ u_int tcp_rcv_nxt;
+ u_int tcp_rcv_wnd;
+ u_int tcp_snd_nxt;
+ u_int tcp_snd_wnd;
+ u_int tcp_snd_buf;
+ u_int tcp_cwnd;
+ u_int tcp_ssthresh;
+ u_int tcp_rtime;
+ u_int tcp_mss;
+ u_int tcp_flags;
+ u_int tcp_rcv_ts;
+ u_int tcp_snd_ts;
+ u_int tcp_keep_idle;
+ u_int tcp_keep_intvl;
+ u_int tcp_keep_cnt;
+ u_int tcp_pad2[16];
+};
+
#endif /* __NETINET_TCP_H */
/*********************************************************************************************************
END
diff --git a/SylixOS/include/network/lwip/sockets.h b/SylixOS/include/network/lwip/sockets.h
index b99c61b..9643f41 100644
--- a/SylixOS/include/network/lwip/sockets.h
+++ b/SylixOS/include/network/lwip/sockets.h
@@ -320,6 +320,9 @@ struct linger {
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
+#ifdef SYLIXOS /* SylixOS Add TCP_DESC Support */
+#define TCP_DESC 0x80
+#endif /* SYLIXOS */
/* SylixOS Add TCP MD5 SIG Support */
#ifdef SYLIXOS
diff --git a/SylixOS/loader/include/loader_vppatch.h b/SylixOS/loader/include/loader_vppatch.h
index 8af3e69..c7b2aff 100644
--- a/SylixOS/loader/include/loader_vppatch.h
+++ b/SylixOS/loader/include/loader_vppatch.h
@@ -84,8 +84,8 @@ typedef struct lw_ld_vproc {
#define __LW_VP_INIT 0
#define __LW_VP_RUN 1
-#define __LW_VP_EXIT 2
-#define __LW_VP_STOP 3
+#define __LW_VP_STOP 2
+#define __LW_VP_EXIT 3
INT VP_iStatus; /* 当前进程状态 */
INT VP_iExitCode; /* 结束代码 */
INT VP_iSigCode; /* iSigCode */
diff --git a/SylixOS/loader/src/loader_vppatch.c b/SylixOS/loader/src/loader_vppatch.c
index aa6dab7..387aa52 100644
--- a/SylixOS/loader/src/loader_vppatch.c
+++ b/SylixOS/loader/src/loader_vppatch.c
@@ -1125,7 +1125,6 @@ __recheck:
LW_LD_VPROC *pvprocChild = _LIST_ENTRY(plineList, LW_LD_VPROC, VP_lineBrother);
pvprocChild->VP_pvprocFather = LW_NULL; /* 子进程设为孤儿进程 */
-
if (pvprocChild->VP_iStatus == __LW_VP_EXIT) { /* 子进程为僵尸进程 */
__resReclaimReq((PVOID)pvprocChild); /* 请求释放进程资源 */
}
diff --git a/SylixOS/loader/src/loader_wait.c b/SylixOS/loader/src/loader_wait.c
index 256a14e..c87e936 100644
--- a/SylixOS/loader/src/loader_wait.c
+++ b/SylixOS/loader/src/loader_wait.c
@@ -249,6 +249,9 @@ static BOOL __haveThisChild (LW_LD_VPROC *pvproc, pid_t pidChild)
pidChild == 0 子进程中组 ID 相同的
pidChild == -1 任何子进程
pidChild < -1 子进程中组 ID 为 pid 绝对值的
+
+ 此函数为信号响应函数, 可能之前已占用有关资源锁, 如果在这里回收子进程资源, 可能造成死锁,
+ 所以这里在获取到进程返回信息后, 通知内核回收线程去回收资源.
*********************************************************************************************************/
static INT __reclaimAChild (LW_LD_VPROC *pvproc,
pid_t pidChild,
@@ -304,6 +307,9 @@ static INT __reclaimAChild (LW_LD_VPROC *pvproc,
if (stat_loc) {
*stat_loc = SET_EXITSTATUS(pvprocChild->VP_iExitCode); /* 子进程正常退出 */
}
+ pvprocChild->VP_pvprocFather = LW_NULL;
+ _List_Line_Del(&pvprocChild->VP_lineBrother,
+ &pvproc->VP_plineChild); /* 将子进程从链表中退出 */
bHasEvent = LW_TRUE;
bNeedReclaim = LW_TRUE;
break;
@@ -339,7 +345,7 @@ static INT __reclaimAChild (LW_LD_VPROC *pvproc,
__tickToTimeval(pvprocChild->VP_clockSystem, &prusage->ru_stime);
}
if (bNeedReclaim) {
- vprocReclaim(pvprocChild, LW_TRUE); /* 回收子进程资源 */
+ __resReclaimReq((PVOID)pvprocChild); /* 请求内核释放进程资源 */
}
return (1);
diff --git a/SylixOS/net/lwip/src/api/sockets.c b/SylixOS/net/lwip/src/api/sockets.c
index 8cc7054..4647741 100644
--- a/SylixOS/net/lwip/src/api/sockets.c
+++ b/SylixOS/net/lwip/src/api/sockets.c
@@ -69,6 +69,10 @@
#include LWIP_HOOK_FILENAME
#endif
+#ifdef SYLIXOS /* SylixOS Need TCP_STATE */
+#include <netinet/tcp.h>
+#endif
+
/* If the netconn API is not required publicly, then we include the necessary
files here to get the implementation */
#if !LWIP_NETCONN
@@ -3383,6 +3387,42 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
#if LWIP_TCP
/* Level: IPPROTO_TCP */
case IPPROTO_TCP:
+#ifdef SYLIXOS /* SylixOS Add TCP_DESC */
+ if (optname == TCP_DESC) {
+ LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, sizeof(struct tcp_desc), NETCONN_TCP);
+ struct tcp_desc *desc = (struct tcp_desc *)optval;
+ if (sock->conn->pcb.tcp->state == LISTEN) {
+ struct tcp_pcb_listen *lpcb = (struct tcp_pcb_listen *)lpcb;
+ lib_bzero(desc, sizeof(struct tcp_desc));
+ desc->tcp_state = LISTEN;
+ desc->tcp_backlog = lpcb->backlog;
+ desc->tcp_accpend = lpcb->accepts_pending;
+ } else {
+ struct tcp_pcb *pcb = sock->conn->pcb.tcp;
+ desc->tcp_state = pcb->state;
+ desc->tcp_backlog = 0;
+ desc->tcp_accpend = 0;
+ desc->tcp_rcv_scale = pcb->rcv_scale;
+ desc->tcp_snd_scale = pcb->snd_scale;
+ desc->tcp_rcv_nxt = pcb->rcv_nxt;
+ desc->tcp_rcv_wnd = pcb->rcv_wnd;
+ desc->tcp_snd_nxt = pcb->snd_nxt;
+ desc->tcp_snd_wnd = pcb->snd_wnd;
+ desc->tcp_snd_buf = pcb->snd_buf;
+ desc->tcp_cwnd = pcb->cwnd;
+ desc->tcp_ssthresh = pcb->ssthresh;
+ desc->tcp_rtime = pcb->rtime;
+ desc->tcp_mss = pcb->mss;
+ desc->tcp_flags = pcb->flags;
+ desc->tcp_rcv_ts = pcb->ts_recent;
+ desc->tcp_snd_ts = pcb->ts_lastacksent;
+ desc->tcp_keep_idle = pcb->keep_idle;
+ desc->tcp_keep_intvl = pcb->keep_intvl;
+ desc->tcp_keep_cnt = pcb->keep_cnt;
+ }
+ break;
+ }
+#endif /* SYLIXOS */
/* Special case: all IPPROTO_TCP option take an int */
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, int, NETCONN_TCP);
if (sock->conn->pcb.tcp->state == LISTEN) {
diff --git a/SylixOS/posix/aio/aio_lib.c b/SylixOS/posix/aio/aio_lib.c
index 9343874..b3c6281 100644
--- a/SylixOS/posix/aio/aio_lib.c
+++ b/SylixOS/posix/aio/aio_lib.c
@@ -733,6 +733,14 @@ static PVOID __aioThread (PVOID pvArg)
API_SemaphoreMPend(paiorc->aiorc_mutex, LW_OPTION_WAIT_INFINITE);
+ if (paiorc->aiorc_iscancel) {
+ paioreq->aioreq_return = PX_ERROR;
+ paioreq->aioreq_error = ECANCELED;
+ paioreq->aioreq_flags &= ~AIO_REQ_BUSY; /* 清除忙标志 */
+ API_SemaphoreMPost(paiorc->aiorc_mutex);
+ continue;
+ }
+
_List_Line_Del(paiorc->aiorc_plineaiocb,
&paiorc->aiorc_plineaiocb); /* 将处理节点从 paiorc 中删除 */