File tree Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ extern uint threadpool_oversubscribe; /* Maximum active threads in group */
27
27
28
28
29
29
/* Common thread pool routines, suitable for different implementations */
30
+ extern void threadpool_cleanup_connection (THD * thd );
30
31
extern void threadpool_remove_connection (THD * thd );
31
32
extern int threadpool_process_request (THD * thd );
32
33
extern int threadpool_add_connection (THD * thd );
Original file line number Diff line number Diff line change @@ -168,22 +168,28 @@ int threadpool_add_connection(THD *thd)
168
168
return retval;
169
169
}
170
170
171
+ /*
172
+ threadpool_cleanup_connection() does the bulk of connection shutdown work.
173
+ Usually called from threadpool_remove_connection(), but rarely it might
174
+ be called also in the main polling thread if connection initialization fails.
175
+ */
176
+ void threadpool_cleanup_connection (THD *thd)
177
+ {
178
+ thd->net .reading_or_writing = 0 ;
179
+ end_connection (thd);
180
+ close_connection (thd, 0 );
181
+ unlink_thd (thd);
182
+ mysql_cond_broadcast (&COND_thread_count);
183
+ }
184
+
171
185
172
186
void threadpool_remove_connection (THD *thd)
173
187
{
174
-
175
188
Worker_thread_context worker_context;
176
189
worker_context.save ();
177
-
178
190
thread_attach (thd);
179
- thd->net .reading_or_writing = 0 ;
180
-
181
- end_connection (thd);
182
- close_connection (thd, 0 );
183
-
184
- unlink_thd (thd);
185
- mysql_cond_broadcast (&COND_thread_count);
186
191
192
+ threadpool_cleanup_connection (thd);
187
193
/*
188
194
Free resources associated with this connection:
189
195
mysys thread_var and PSI thread.
Original file line number Diff line number Diff line change @@ -1255,7 +1255,7 @@ void tp_add_connection(THD *thd)
1255
1255
else
1256
1256
{
1257
1257
/* Allocation failed */
1258
- threadpool_remove_connection (thd);
1258
+ threadpool_cleanup_connection (thd);
1259
1259
}
1260
1260
DBUG_VOID_RETURN;
1261
1261
}
Original file line number Diff line number Diff line change @@ -667,7 +667,7 @@ void tp_add_connection(THD *thd)
667
667
if (!con)
668
668
{
669
669
tp_log_warning (" Allocation failed" , " tp_add_connection" );
670
- threadpool_remove_connection (thd);
670
+ threadpool_cleanup_connection (thd);
671
671
return ;
672
672
}
673
673
@@ -685,7 +685,7 @@ void tp_add_connection(THD *thd)
685
685
else
686
686
{
687
687
/* Likely memory pressure */
688
- login_callback ( NULL , con, NULL ); /* deletes connection if something goes wrong */
688
+ threadpool_cleanup_connection (thd);
689
689
}
690
690
}
691
691
You can’t perform that action at this time.
0 commit comments