request


Object Hierarchy:

FastCGI.request FastCGI.request FastCGI.request

Description:

[ CCode ( cname = "FCGX_Request" , destroy_function = "" , has_type_id = false ) ]
public struct request

State associated with a request.

This is the API for multi-threaded code. Code should be structured like this:

int descriptor;
Mutex mutex;
void handler() {
FastCGI.request request;
assert(FastCGI.request.init(out request, descriptor) == 0);
while (true) {
mutex.lock () ;
var fail = request.accept() < 0;
mutex.unlock();
if (fail)
break;
// Process request
request.finish();
}
request.close(false);
}
void main() {
mutex = new Mutex();
assert(FastCGI.init() == 0);
stderr.printf("I:open_socket path=\"%s\" backlog=%d\n", socket_path, backlog);
descriptor = FastCGI.open_socket(socket_path, backlog);
assert(descriptor != -1);
try {
while (thread_count > 1) {
Thread.create<void>(handler, false);
thread_count--;
}
handler();
} catch(ThreadError e) {
// Handle error
}
}

It is important that only one thread at a time attempt to call accept, hence the mutex. The request can be read from the client using environment and the response can be written to the client using out.


Namespace: FastCGI
Package: fcgi

Content:

Static methods:

Methods:

Fields:




2022 vala-language.org