Skip to content

Commit ba1757d

Browse files
committed
Merge pull request #131 from Sage/master
clear rows before invoking nextRows callback
2 parents 048124c + 2183a3c commit ba1757d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/reader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,22 @@ void Reader::EIO_AfterNextRows(uv_work_t* req, int status) {
119119
baton->busy = false;
120120
baton->connection->Unref();
121121
// transfer callback to local and dispose persistent handle
122-
// must be done before invoking callback because callback may set another callback into baton->callback
123122
Local<Function> cb = uni::HandleToLocal(uni::Deref(baton->callback));
124123
baton->callback.Dispose();
125124
baton->callback.Clear();
126125

127126
Handle<Value> argv[2];
128127
Connection::handleResult(baton, argv);
129-
node::MakeCallback(Context::GetCurrent()->Global(), cb, 2, argv);
130-
128+
131129
baton->ResetRows();
132130
if (baton->done || baton->error) {
133131
// free occi resources so that we don't run out of cursors if gc is not fast enough
134132
// reader destructor will delete the baton and everything else.
135133
baton->ResetStatement();
136134
}
137135
delete req;
136+
137+
// invoke callback at the very end because callback may re-enter nextRows.
138+
node::MakeCallback(Context::GetCurrent()->Global(), cb, 2, argv);
138139
}
139140

0 commit comments

Comments
 (0)