Skip to content

Commit

Permalink
Fix incompatible function pointers
Browse files Browse the repository at this point in the history
Normal function pointers are not compatible with static members, so we have to wrap them in Lambdas.
  • Loading branch information
FooBarWidget committed Oct 4, 2024
1 parent 687cdf2 commit 0f30ffa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ dumpEnvvars(const string &workDir) {
NULL
};
SubprocessInfo info;
runCommand(command, info, true, true,
boost::bind(reopenStdout, fileno(f)));
int fd = fileno(f);
runCommand(command, info, true, true, [=]() { reopenStdout(fd); });
fclose(f);
}

Expand All @@ -236,8 +236,8 @@ dumpUserInfo(const string &workDir) {
NULL
};
SubprocessInfo info;
runCommand(command, info, true, true,
boost::bind(reopenStdout, fileno(f)));
int fd = fileno(f);
runCommand(command, info, true, true, [=]() { reopenStdout(fd); });
fclose(f);
}

Expand Down
24 changes: 15 additions & 9 deletions src/cxx_supportlib/ServerKit/HttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ class HttpServer: public BaseServer<DerivedServer, Client> {
if (!req->bodyChannel.acceptingInput()) {
if (req->bodyChannel.mayAcceptInputLater()) {
client->input.stop();
req->bodyChannel.consumedCallback =
onRequestBodyChannelConsumed;
req->bodyChannel.consumedCallback = [](Channel *channel, unsigned int size) {
onRequestBodyChannelConsumed(channel, size);
};
return Channel::Result(0, false);
} else {
return Channel::Result(0, true);
Expand Down Expand Up @@ -436,8 +437,9 @@ class HttpServer: public BaseServer<DerivedServer, Client> {
return Channel::Result(remaining, false);
} else if (req->bodyChannel.mayAcceptInputLater()) {
client->input.stop();
req->bodyChannel.consumedCallback =
onRequestBodyChannelConsumed;
req->bodyChannel.consumedCallback = [](Channel *channel, unsigned int size) {
onRequestBodyChannelConsumed(channel, size);
};
return Channel::Result(remaining, false);
} else {
return Channel::Result(remaining, true);
Expand Down Expand Up @@ -467,8 +469,9 @@ class HttpServer: public BaseServer<DerivedServer, Client> {
if (!req->bodyChannel.acceptingInput()) {
if (req->bodyChannel.mayAcceptInputLater()) {
client->input.stop();
req->bodyChannel.consumedCallback =
onRequestBodyChannelConsumed;
req->bodyChannel.consumedCallback = [](Channel *channel, unsigned int size) {
onRequestBodyChannelConsumed(channel, size);
};
return Channel::Result(0, false);
} else {
return Channel::Result(0, true);
Expand Down Expand Up @@ -509,7 +512,9 @@ class HttpServer: public BaseServer<DerivedServer, Client> {
req->bodyChannel.feed(MemoryKit::mbuf());
} else if (req->bodyChannel.mayAcceptInputLater()) {
client->input.stop();
req->bodyChannel.consumedCallback = onRequestBodyChannelConsumed;
req->bodyChannel.consumedCallback = [](Channel *channel, unsigned int size) {
onRequestBodyChannelConsumed(channel, size);
};
}
}
}
Expand Down Expand Up @@ -606,8 +611,9 @@ class HttpServer: public BaseServer<DerivedServer, Client> {
} else if (req->bodyChannel.mayAcceptInputLater()) {
SKC_TRACE(client, 3, "BodyChannel currently busy; will feed "
"error to bodyChannel later");
req->bodyChannel.consumedCallback =
onRequestBodyChannelConsumed_onBodyError;
req->bodyChannel.consumedCallback = [](Channel *channel, unsigned int size) {
onRequestBodyChannelConsumed_onBodyError(channel, size);
};
req->bodyError = errcode;
return Channel::Result(-1, false);
} else {
Expand Down

0 comments on commit 0f30ffa

Please sign in to comment.