Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
0983ca7c
Commit
0983ca7c
authored
Feb 17, 2016
by
Stephen R. van den Berg
Browse files
Options
Downloads
Patches
Plain Diff
pgsql: Expedite filedescriptor close when leaving scope.
parent
a08aebc9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/Sql.pmod/pgsql.pike
+12
-3
12 additions, 3 deletions
lib/modules/Sql.pmod/pgsql.pike
lib/modules/Sql.pmod/pgsql_util.pmod
+12
-8
12 additions, 8 deletions
lib/modules/Sql.pmod/pgsql_util.pmod
with
24 additions
and
11 deletions
lib/modules/Sql.pmod/pgsql.pike
+
12
−
3
View file @
0983ca7c
...
@@ -597,6 +597,10 @@ private int datarowdebugcount;
...
@@ -597,6 +597,10 @@ private int datarowdebugcount;
#endif
#endif
final void _processloop(.pgsql_util.conxion ci) {
final void _processloop(.pgsql_util.conxion ci) {
if(c && (!ci || c!=ci)) // If we are switching or dropping connections
c->close(); // force a close on the old socket
if(!this) // Oops, current object already destructed
return;
(c=ci)->socket->set_id(procmessage);
(c=ci)->socket->set_id(procmessage);
cancelsecret=0;
cancelsecret=0;
portal=0;
portal=0;
...
@@ -651,6 +655,10 @@ private void procmessage() {
...
@@ -651,6 +655,10 @@ private void procmessage() {
if(!sizeof(cr)) { // Preliminary check, fast path
if(!sizeof(cr)) { // Preliminary check, fast path
Thread.MutexKey lock=cr->fillreadmux->lock();
Thread.MutexKey lock=cr->fillreadmux->lock();
if(!sizeof(cr)) { // Check for real
if(!sizeof(cr)) { // Check for real
if(!cr->fillread) {
lock=0;
throw(MAGICTERMINATE); // Force proper termination
}
cr->procmsg=1;
cr->procmsg=1;
lock=0;
lock=0;
return; // Terminate thread, wait for callback
return; // Terminate thread, wait for callback
...
@@ -1196,8 +1204,9 @@ private void procmessage() {
...
@@ -1196,8 +1204,9 @@ private void procmessage() {
//! This function is PostgreSQL-specific, and thus it is not available
//! This function is PostgreSQL-specific, and thus it is not available
//! through the generic SQL-interface.
//! through the generic SQL-interface.
/*semi*/final void close() {
/*semi*/final void close() {
if(qportals && qportals->size())
catch(cancelquery());
catch(cancelquery());
catch(c->
sendterminat
e());
catch(c->
clos
e());
c=0;
c=0;
destruct(waitforauthready);
destruct(waitforauthready);
}
}
...
@@ -1253,7 +1262,7 @@ private int reconnect() {
...
@@ -1253,7 +1262,7 @@ private int reconnect() {
#ifdef PG_STATS
#ifdef PG_STATS
prepstmtused=0;
prepstmtused=0;
#endif
#endif
c->
sendterminat
e();
c->
clos
e();
c=0;
c=0;
PD("Flushing old cache\n");
PD("Flushing old cache\n");
foreach(_prepareds;;mapping tp)
foreach(_prepareds;;mapping tp)
...
...
This diff is collapsed.
Click to expand it.
lib/modules/Sql.pmod/pgsql_util.pmod
+
12
−
8
View file @
0983ca7c
...
@@ -335,19 +335,23 @@ outer:
...
@@ -335,19 +335,23 @@ outer:
catch(connectfail());
catch(connectfail());
}
}
final void sendterminate() {
Thread.MutexKey lock=i->fillreadmux->lock();
if(i->fillread) // Delayed close() after flushing the output buffer
i->fillread.signal(), i->fillread=0;
lock=0;
}
final int close() {
final int close() {
int ret;
int ret;
{ Thread.MutexKey lock=i->fillreadmux->lock();
if(i->fillread) { // Delayed close() after flushing the output buffer
i->fillread.signal();
i->fillread=0;
lock=0;
PD("%d>Close socket read, flush write\n",socket->query_fd());
ret=socket->close("r");
i->read_cb(socket->query_id(),0);
return ret;
}
lock=0;
}
destruct(nostash);
destruct(nostash);
PD("%d>Close socket\n",socket->query_fd());
PD("%d>Close socket\n",socket->query_fd());
ret=socket->close();
ret=socket->close();
sendterminate();
foreach(closecallbacks;function(void|mixed:void) closecb;)
foreach(closecallbacks;function(void|mixed:void) closecb;)
closecb();
closecb();
closecallbacks=(<>);
closecallbacks=(<>);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment