diff options
| author | 杨威 <[email protected]> | 2023-05-25 18:03:58 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2023-05-26 14:40:13 +0800 |
| commit | 00e08fa61d468f4b652f06c047d85d7734280650 (patch) | |
| tree | 2275d7ef9eb4f34b3958f486ed45430aeb64772a | |
| parent | 7483ec1b6e457c1c479c5baa10ca3a4d7376ecde (diff) | |
🐞 fix(stream_state_data_process): 修复同时返回kill_other和dropme时,处理逻辑错误的bugv4.3.4
| -rw-r--r-- | src/dealpkt/callapp.c | 43 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 16 |
2 files changed, 37 insertions, 22 deletions
diff --git a/src/dealpkt/callapp.c b/src/dealpkt/callapp.c index 6824f45..a828b57 100644 --- a/src/dealpkt/callapp.c +++ b/src/dealpkt/callapp.c @@ -563,7 +563,7 @@ static int stream_state_pending_process(struct streaminfo *a_stream,const void * }
else
{
- if ((entry_ret & APP_STATE_GIVEME) == APP_STATE_GIVEME || APP_STATE_GIVEME == 0)
+ if ((entry_ret & APP_STATE_GIVEME) == APP_STATE_GIVEME || entry_ret == APP_STATE_GIVEME)
{
giveme_cnt++;
}
@@ -657,7 +657,7 @@ static int stream_state_data_process(struct streaminfo *a_stream,const void *thi }
else
{
- if ((entry_ret & APP_STATE_GIVEME) == APP_STATE_GIVEME || APP_STATE_GIVEME == 0)
+ if ((entry_ret & APP_STATE_GIVEME) == APP_STATE_GIVEME || entry_ret == APP_STATE_GIVEME)
{
giveme_cnt++;
}
@@ -683,6 +683,10 @@ static int stream_state_data_process(struct streaminfo *a_stream,const void *thi }
iter_current = iter_current->next;
plug_entry_kick_out_one(to_remove, a_stream);
+ if (to_remove == prev) // if we remove the 'prev', update 'prev'
+ {
+ prev = iter_prev;
+ }
}
else
{
@@ -690,34 +694,31 @@ static int stream_state_data_process(struct streaminfo *a_stream,const void *thi iter_current = iter_current->next;
}
}
- current = current->next;
}
- else
+ // Check and process APP_STATE_DROPME separately from APP_STATE_KILL_OTHER or APP_STATE_KILL_FOLLOW.
+ if (entry_ret & APP_STATE_DROPME)
{
- if (entry_ret&APP_STATE_DROPME)
+ to_remove = NULL;
+ if (prev != NULL)
{
- to_remove = NULL;
- if (prev != NULL)
- {
- prev->next = current->next;
- to_remove = current;
- current = current->next;
- }
- else
- {
- head = current->next;
- to_remove = current;
- current = current->next;
- }
- sapp_mem_free(SAPP_MEM_DYN_PLUG_CTRL,a_stream->threadnum,to_remove);
+ prev->next = current->next;
+ to_remove = current;
+ current = current->next;
}
else
{
- prev = current;
+ head = current->next;
+ to_remove = current;
current = current->next;
}
+ sapp_mem_free(SAPP_MEM_DYN_PLUG_CTRL,a_stream->threadnum,to_remove);
}
- }
+ else
+ {
+ prev = current;
+ current = current->next;
+ }
+ }
if(head != NULL)
{
*opstate= OP_STATE_DATA;
diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index 2a511c2..0b99638 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -892,11 +892,25 @@ char testudpApp_2(struct streaminfo *pstream,void **pme, int thread_seq,void *a_ } -char testtcpApp_1(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet) +char testtcpApp_3_dropme_killother(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet) { struct tcpdetail *pdetail=(struct tcpdetail *)pstream->pdetail; if(pdetail->clientpktnum >3) + { + return APP_STATE_DROPME|APP_STATE_KILL_OTHER; + } + else + { + return APP_STATE_GIVEME; + } +} + +char testtcpApp_10(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet) +{ + struct tcpdetail *pdetail=(struct tcpdetail *)pstream->pdetail; + + if(pdetail->clientpktnum >10) return APP_STATE_DROPME; else return APP_STATE_GIVEME; |
