aboutsummaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src/socket
diff options
context:
space:
mode:
Diffstat (limited to 'stacks/lwip_stack/lwip_src/socket')
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c28
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h3
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c19
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c33
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h1
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_tcp.c2
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_udp.c2
7 files changed, 88 insertions, 0 deletions
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
index 6af2a77..292c17a 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
@@ -522,6 +522,34 @@ sbr_com_lock_common (sbr_socket_t * sk)
}
+void
+sbr_com_fork_parent (sbr_socket_t * sk, pid_t p)
+{
+ i32 ref = ss_inc_fork_ref (sbr_get_conn (sk));
+ NSSBR_LOGINF ("inc fork ref] fd=%d, p=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, ref, sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+}
+
+void
+sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c)
+{
+ if (ss_add_pid (sbr_get_conn (sk), c) != 0)
+ {
+ NSSBR_LOGERR
+ ("add pid failed] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+ }
+ else
+ {
+ NSSBR_LOGINF
+ ("add pid ok] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+ }
+}
+
/*****************************************************************************
* Prototype : sbr_com_unlock_common
* Description : unlock common
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
index 054393b..1be44cb 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
@@ -150,6 +150,9 @@ int sbr_get_sockaddr_and_len (u16 port, spl_ip_addr_t * ip_addr,
struct sockaddr *addr, socklen_t * addrlen);
void sbr_com_set_app_info (sbr_socket_t * sk, void *appinfo);
+void sbr_com_fork_parent (sbr_socket_t * sk, pid_t p);
+void sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c);
+
#ifdef __cplusplus
/* *INDENT-OFF* */
}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
index 94ef483..920d73d 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
@@ -44,6 +44,25 @@ sbr_init_protocol ()
}
/*****************************************************************************
+* Prototype : sbr_fork_protocol
+* Description : init protocol
+* Input : None
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+int
+sbr_fork_protocol ()
+{
+ pid_t pid = updata_sys_pid ();
+
+ NSSBR_LOGINF ("update pid in child]pid=%d", pid);
+ return sbr_fork_stackx ();
+}
+
+/*****************************************************************************
* Prototype : sbr_get_fdopt
* Description : get fdopt by domain type protocol
* Input : int domain
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
index 331eee1..f3cb5b5 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
@@ -172,6 +172,39 @@ sbr_init_stackx ()
}
/*****************************************************************************
+* Prototype : sbr_fork_stackx
+* Description : init stackx res
+* Input : None
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+int
+sbr_fork_stackx ()
+{
+
+ if (sbr_attach_group_array () != 0)
+ {
+ NSSBR_LOGERR ("sbr_attach_group_array failed");
+ return -1;
+ }
+
+ NSSBR_LOGDBG ("sbr_attach_group_array ok");
+
+ if (sbr_init_tx_pool () != 0)
+ {
+ NSSBR_LOGERR ("init tx pool failed");
+ return -1;
+ }
+
+ NSSBR_LOGDBG ("init tx pool ok");
+ NSSBR_LOGDBG ("sbr_fork_stackx ok");
+ return 0;
+}
+
+/*****************************************************************************
* Prototype : sbr_malloc_conn_for_sk
* Description : malloc netconn for sk,need add pid
* Input : sbr_socket_t* sk
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
index e139644..73cec7f 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
@@ -56,6 +56,7 @@ sbr_get_spl_msg_box (sbr_socket_t * sk, u8 tos)
}
int sbr_init_stackx ();
+int sbr_fork_stackx ();
int sbr_malloc_conn_for_sk (sbr_socket_t * sk, spl_netconn_type_t type);
int sbr_init_conn_for_accept (sbr_socket_t * sk, spl_netconn_t * conn);
void sbr_free_conn_from_sk (sbr_socket_t * sk);
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
index c64dc7b..3225c2f 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
@@ -1690,6 +1690,8 @@ sbr_fdopt tcp_fdopt = {
.peak = sbr_com_peak,
.lock_common = sbr_com_lock_common,
.unlock_common = sbr_com_unlock_common,
+ .fork_parent = sbr_com_fork_parent,
+ .fork_child = sbr_com_fork_child,
.ep_getevt = stackx_eventpoll_getEvt,
.ep_ctl = stackx_eventpoll_triggle,
.set_close_stat = NULL,
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
index cf08731..69b822b 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
@@ -1163,6 +1163,8 @@ sbr_fdopt udp_fdopt = {
.peak = sbr_com_peak,
.lock_common = sbr_com_lock_common,
.unlock_common = sbr_com_unlock_common,
+ .fork_parent = sbr_com_fork_parent,
+ .fork_child = sbr_com_fork_child,
.ep_getevt = stackx_eventpoll_getEvt,
.ep_ctl = stackx_eventpoll_triggle,
.set_close_stat = NULL,