MEDIUM: sink: Use the sedesc to report and detect end of processing

Just like for other applets, we now use the SE descriptor instead of the
channel to report error and end-of-stream.
This commit is contained in:
Christopher Faulet 2023-03-31 11:25:55 +02:00
parent 4b866959d8
commit a739dc22c5

View File

@ -318,17 +318,13 @@ static void sink_forward_io_handler(struct appctx *appctx)
size_t len, cnt, ofs, last_ofs; size_t len, cnt, ofs, last_ofs;
int ret = 0; int ret = 0;
if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW))))
goto out;
/* if stopping was requested, close immediately */ /* if stopping was requested, close immediately */
if (unlikely(stopping)) if (unlikely(stopping))
goto close; goto close;
if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto close;
/* con closed by server side */
if ((sc_oc(sc)->flags & CF_SHUTW))
goto close;
/* if the connection is not established, inform the stream that we want /* if the connection is not established, inform the stream that we want
* to be notified whenever the connection completes. * to be notified whenever the connection completes.
*/ */
@ -336,7 +332,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
applet_need_more_data(appctx); applet_need_more_data(appctx);
se_need_remote_conn(appctx->sedesc); se_need_remote_conn(appctx->sedesc);
applet_have_more_data(appctx); applet_have_more_data(appctx);
return; goto out;
} }
HA_SPIN_LOCK(SFT_LOCK, &sft->lock); HA_SPIN_LOCK(SFT_LOCK, &sft->lock);
@ -427,13 +423,13 @@ static void sink_forward_io_handler(struct appctx *appctx)
} }
HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock); HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
out:
/* always drain data from server */ /* always drain data from server */
co_skip(sc_oc(sc), sc_oc(sc)->output); co_skip(sc_oc(sc), sc_oc(sc)->output);
return; return;
close: close:
sc_shutw(sc); se_fl_set(appctx->sedesc, SE_FL_EOS|SE_FL_EOI);
sc_shutr(sc);
} }
/* /*
@ -454,18 +450,13 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
int ret = 0; int ret = 0;
char *p; char *p;
if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW))))
goto out;
/* if stopping was requested, close immediately */ /* if stopping was requested, close immediately */
if (unlikely(stopping)) if (unlikely(stopping))
goto close; goto close;
/* an error was detected */
if (unlikely(sc_ic(sc)->flags & CF_SHUTW))
goto close;
/* con closed by server side */
if ((sc_oc(sc)->flags & CF_SHUTW))
goto close;
/* if the connection is not established, inform the stream that we want /* if the connection is not established, inform the stream that we want
* to be notified whenever the connection completes. * to be notified whenever the connection completes.
*/ */
@ -473,7 +464,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
applet_need_more_data(appctx); applet_need_more_data(appctx);
se_need_remote_conn(appctx->sedesc); se_need_remote_conn(appctx->sedesc);
applet_have_more_data(appctx); applet_have_more_data(appctx);
return; goto out;
} }
HA_SPIN_LOCK(SFT_LOCK, &sft->lock); HA_SPIN_LOCK(SFT_LOCK, &sft->lock);
@ -559,13 +550,14 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
} }
HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock); HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
out:
/* always drain data from server */ /* always drain data from server */
co_skip(sc_oc(sc), sc_oc(sc)->output); co_skip(sc_oc(sc), sc_oc(sc)->output);
return; return;
close: close:
sc_shutw(sc); se_fl_set(appctx->sedesc, SE_FL_EOS|SE_FL_EOI);
sc_shutr(sc); goto out;
} }
void __sink_forward_session_deinit(struct sink_forward_target *sft) void __sink_forward_session_deinit(struct sink_forward_target *sft)