Make sure to always delete the remote serializer.

There were two problems actually: the iomanager wasn't properly
deleting sourcesl; and in some situations, the remote serialize wasn't
registered with it to begin with.

Addresses BIT-1306 and probably also BIT-1356.
This commit is contained in:
Robin Sommer 2015-04-10 17:27:28 -07:00
parent 1132470b05
commit 0620bc970a
5 changed files with 36 additions and 4 deletions

View file

@ -1,4 +1,13 @@
2.3-690 | 2015-04-10 21:51:10 -0700
* Make sure to always delete the remote serializer. Addresses
BIT-1306 and probably also BIT-1356. (Robin Sommer)
* Cleaning up --help. -D and -Y/y were still listed, even though
they had no effect anymore. Removing some dead code along with -D.
Addresses BIT-1372. (Robin Sommer)
2.3-688 | 2015-04-10 08:10:44 -0700 2.3-688 | 2015-04-10 08:10:44 -0700
* Update SQLite to 3.8.8.3. * Update SQLite to 3.8.8.3.

View file

@ -1 +1 @@
2.3-688 2.3-690

View file

@ -542,6 +542,9 @@ RemoteSerializer::RemoteSerializer()
current_msgtype = 0; current_msgtype = 0;
current_args = 0; current_args = 0;
source_peer = 0; source_peer = 0;
// Register as a "dont-count" source first, we may change that later.
iosource_mgr->Register(this, true);
} }
RemoteSerializer::~RemoteSerializer() RemoteSerializer::~RemoteSerializer()
@ -571,8 +574,6 @@ void RemoteSerializer::Enable()
Fork(); Fork();
iosource_mgr->Register(this);
Log(LogInfo, fmt("communication started, parent pid is %d, child pid is %d", getpid(), child_pid)); Log(LogInfo, fmt("communication started, parent pid is %d, child pid is %d", getpid(), child_pid));
initialized = 1; initialized = 1;
} }
@ -612,6 +613,9 @@ void RemoteSerializer::Fork()
if ( child_pid ) if ( child_pid )
return; return;
// Register as a "does-count" source now.
iosource_mgr->Register(this, false);
// If we are re-forking, remove old entries // If we are re-forking, remove old entries
loop_over_list(peers, i) loop_over_list(peers, i)
RemovePeer(peers[i]); RemovePeer(peers[i]);

View file

@ -24,6 +24,7 @@ Manager::~Manager()
for ( SourceList::iterator i = sources.begin(); i != sources.end(); ++i ) for ( SourceList::iterator i = sources.begin(); i != sources.end(); ++i )
{ {
(*i)->src->Done(); (*i)->src->Done();
delete (*i)->src;
delete *i; delete *i;
} }
@ -183,9 +184,24 @@ finished:
void Manager::Register(IOSource* src, bool dont_count) void Manager::Register(IOSource* src, bool dont_count)
{ {
// First see if we already have registered that source. If so, just
// adjust dont_count.
for ( SourceList::iterator i = sources.begin(); i != sources.end(); ++i )
{
if ( (*i)->src == src )
{
if ( (*i)->dont_count != dont_count )
// Adjust the global counter.
dont_counts += (dont_count ? 1 : -1);
return;
}
}
src->Init(); src->Init();
Source* s = new Source; Source* s = new Source;
s->src = src; s->src = src;
s->dont_count = dont_count;
if ( dont_count ) if ( dont_count )
++dont_counts; ++dont_counts;

View file

@ -29,7 +29,9 @@ public:
~Manager(); ~Manager();
/** /**
* Registers an IOSource with the manager. * Registers an IOSource with the manager. If the source is already
* registered, the method will update its *dont_count* value but not
* do anything else.
* *
* @param src The source. The manager takes ownership. * @param src The source. The manager takes ownership.
* *
@ -117,6 +119,7 @@ private:
FD_Set fd_read; FD_Set fd_read;
FD_Set fd_write; FD_Set fd_write;
FD_Set fd_except; FD_Set fd_except;
bool dont_count;
bool Ready(fd_set* read, fd_set* write, fd_set* except) const bool Ready(fd_set* read, fd_set* write, fd_set* except) const
{ return fd_read.Ready(read) || fd_write.Ready(write) || { return fd_read.Ready(read) || fd_write.Ready(write) ||