Fix some wrapped languages

pull/1493/head
Craig Tiller 10 years ago
parent f9e6adf998
commit f508145012
  1. 6
      src/node/ext/server.cc
  2. 10
      src/php/ext/grpc/server.c
  3. 7
      src/python/src/grpc/_adapter/_server.c

@ -161,7 +161,7 @@ NAN_METHOD(Server::New) {
grpc_server *wrapped_server; grpc_server *wrapped_server;
grpc_completion_queue *queue = CompletionQueueAsyncWorker::GetQueue(); grpc_completion_queue *queue = CompletionQueueAsyncWorker::GetQueue();
if (args[0]->IsUndefined()) { if (args[0]->IsUndefined()) {
wrapped_server = grpc_server_create(queue, NULL); wrapped_server = grpc_server_create(NULL);
} else if (args[0]->IsObject()) { } else if (args[0]->IsObject()) {
Handle<Object> args_hash(args[0]->ToObject()); Handle<Object> args_hash(args[0]->ToObject());
Handle<Array> keys(args_hash->GetOwnPropertyNames()); Handle<Array> keys(args_hash->GetOwnPropertyNames());
@ -190,11 +190,12 @@ NAN_METHOD(Server::New) {
return NanThrowTypeError("Arg values must be strings"); return NanThrowTypeError("Arg values must be strings");
} }
} }
wrapped_server = grpc_server_create(queue, &channel_args); wrapped_server = grpc_server_create(&channel_args);
free(channel_args.args); free(channel_args.args);
} else { } else {
return NanThrowTypeError("Server expects an object"); return NanThrowTypeError("Server expects an object");
} }
grpc_server_register_completion_queue(wrapped_server, queue);
Server *server = new Server(wrapped_server); Server *server = new Server(wrapped_server);
server->Wrap(args.This()); server->Wrap(args.This());
NanReturnValue(args.This()); NanReturnValue(args.This());
@ -212,6 +213,7 @@ NAN_METHOD(Server::RequestCall) {
grpc_call_error error = grpc_server_request_call( grpc_call_error error = grpc_server_request_call(
server->wrapped_server, &op->call, &op->details, &op->request_metadata, server->wrapped_server, &op->call, &op->details, &op->request_metadata,
CompletionQueueAsyncWorker::GetQueue(), CompletionQueueAsyncWorker::GetQueue(),
CompletionQueueAsyncWorker::GetQueue(),
new struct tag(new NanCallback(args[0].As<Function>()), ops.release(), new struct tag(new NanCallback(args[0].As<Function>()), ops.release(),
shared_ptr<Resources>(nullptr))); shared_ptr<Resources>(nullptr)));
if (error != GRPC_CALL_OK) { if (error != GRPC_CALL_OK) {

@ -119,12 +119,13 @@ PHP_METHOD(Server, __construct) {
} }
server->queue = grpc_completion_queue_create(); server->queue = grpc_completion_queue_create();
if (args_array == NULL) { if (args_array == NULL) {
server->wrapped = grpc_server_create(server->queue, NULL); server->wrapped = grpc_server_create(NULL);
} else { } else {
php_grpc_read_args_array(args_array, &args); php_grpc_read_args_array(args_array, &args);
server->wrapped = grpc_server_create(server->queue, &args); server->wrapped = grpc_server_create(&args);
efree(args.args); efree(args.args);
} }
grpc_server_register_completion_queue(server->wrapped, server->queue);
} }
/** /**
@ -146,8 +147,9 @@ PHP_METHOD(Server, requestCall) {
object_init(result); object_init(result);
grpc_call_details_init(&details); grpc_call_details_init(&details);
grpc_metadata_array_init(&metadata); grpc_metadata_array_init(&metadata);
error_code = grpc_server_request_call(server->wrapped, &call, &details, error_code =
&metadata, server->queue, NULL); grpc_server_request_call(server->wrapped, &call, &details, &metadata,
server->queue, server->queue, NULL);
if (error_code != GRPC_CALL_OK) { if (error_code != GRPC_CALL_OK) {
zend_throw_exception(spl_ce_LogicException, "request_call failed", zend_throw_exception(spl_ce_LogicException, "request_call failed",
(long)error_code TSRMLS_CC); (long)error_code TSRMLS_CC);

@ -51,8 +51,9 @@ static int pygrpc_server_init(Server *self, PyObject *args, PyObject *kwds) {
&completion_queue)) { &completion_queue)) {
return -1; return -1;
} }
self->c_server = grpc_server_create( self->c_server = grpc_server_create(NULL);
completion_queue->c_completion_queue, NULL); grpc_server_register_completion_queue(self->c_server,
completion_queue->c_completion_queue);
self->completion_queue = completion_queue; self->completion_queue = completion_queue;
Py_INCREF(completion_queue); Py_INCREF(completion_queue);
return 0; return 0;
@ -122,7 +123,7 @@ static const PyObject *pygrpc_server_service(Server *self, PyObject *tag) {
call_error = grpc_server_request_call( call_error = grpc_server_request_call(
self->c_server, &c_tag->call->c_call, &c_tag->call->call_details, self->c_server, &c_tag->call->c_call, &c_tag->call->call_details,
&c_tag->call->recv_metadata, self->completion_queue->c_completion_queue, &c_tag->call->recv_metadata, self->completion_queue->c_completion_queue,
c_tag); self->completion_queue->c_completion_queue, c_tag);
result = pygrpc_translate_call_error(call_error); result = pygrpc_translate_call_error(call_error);
if (result != NULL) { if (result != NULL) {

Loading…
Cancel
Save