...and fix the event ordering issue. Dispatch != QueueEvent

This commit is contained in:
Bernhard Amann 2013-06-09 08:43:17 -04:00
parent 3517c0ba99
commit 655187a4f4

View file

@ -1308,6 +1308,11 @@ void Manager::Put(ReaderFrontend* reader, Value* *vals)
return; return;
} }
#ifdef DEBUG
DBG_LOG(DBG_INPUT, "Put for stream %s",
i->name.c_str());
#endif
int readFields = 0; int readFields = 0;
if ( i->stream_type == TABLE_STREAM ) if ( i->stream_type == TABLE_STREAM )
@ -1631,6 +1636,11 @@ bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals)
return false; return false;
} }
#ifdef DEBUG
DBG_LOG(DBG_INPUT, "SendEvent for event %s with num_vals vals",
name.c_str(), num_vals);
#endif
RecordType *type = handler->FType()->Args(); RecordType *type = handler->FType()->Args();
int num_event_vals = type->NumFields(); int num_event_vals = type->NumFields();
if ( num_vals != num_event_vals ) if ( num_vals != num_event_vals )
@ -1643,7 +1653,8 @@ bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals)
for ( int i = 0; i < num_vals; i++) for ( int i = 0; i < num_vals; i++)
vl->append(ValueToVal(vals[i], type->FieldType(i))); vl->append(ValueToVal(vals[i], type->FieldType(i)));
mgr.Dispatch(new Event(handler, vl)); //mgr.Dispatch(new Event(handler, vl));
mgr.QueueEvent(handler, vl, SOURCE_LOCAL);
for ( int i = 0; i < num_vals; i++ ) for ( int i = 0; i < num_vals; i++ )
delete vals[i]; delete vals[i];
@ -1657,6 +1668,11 @@ void Manager::SendEvent(EventHandlerPtr ev, const int numvals, ...)
{ {
val_list* vl = new val_list; val_list* vl = new val_list;
#ifdef DEBUG
DBG_LOG(DBG_INPUT, "SendEvent with %d vals",
numvals);
#endif
va_list lP; va_list lP;
va_start(lP, numvals); va_start(lP, numvals);
for ( int i = 0; i < numvals; i++ ) for ( int i = 0; i < numvals; i++ )
@ -1671,6 +1687,11 @@ void Manager::SendEvent(EventHandlerPtr ev, list<Val*> events)
{ {
val_list* vl = new val_list; val_list* vl = new val_list;
#ifdef DEBUG
DBG_LOG(DBG_INPUT, "SendEvent with %d vals (list)",
events.size());
#endif
for ( list<Val*>::iterator i = events.begin(); i != events.end(); i++ ) for ( list<Val*>::iterator i = events.begin(); i != events.end(); i++ )
{ {
vl->append( *i ); vl->append( *i );