GRPC Core  0.11.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
server.c File Reference
#include "src/core/surface/server.h"
#include <stdlib.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include "src/core/census/grpc_filter.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/connected_channel.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/stack_lockfree.h"
#include "src/core/surface/call.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/completion_queue.h"
#include "src/core/surface/init.h"
#include "src/core/transport/metadata.h"

Data Structures

struct  listener
 
struct  call_link
 
struct  requested_call
 
struct  channel_registered_method
 
struct  channel_data
 
struct  shutdown_tag
 
struct  call_data
 
struct  request_matcher
 
struct  registered_method
 
struct  channel_broadcaster
 
struct  grpc_server
 
struct  shutdown_cleanup_args
 

Macros

#define SERVER_FROM_CALL_ELEM(elem)   (((channel_data *)(elem)->channel_data)->server)
 

Typedefs

typedef struct listener listener
 
typedef struct call_data call_data
 
typedef struct channel_data channel_data
 
typedef struct registered_method registered_method
 
typedef struct requested_call requested_call
 
typedef struct
channel_registered_method 
channel_registered_method
 
typedef struct shutdown_tag shutdown_tag
 
typedef struct request_matcher request_matcher
 

Enumerations

enum  requested_call_type { BATCH_CALL, REGISTERED_CALL }
 
enum  call_state {
  CALL_CREATED, CALL_WAITING_FOR_SEND, CALL_WAITING_FOR_CONFIG, CALL_WAITING_FOR_PICK,
  CALL_WAITING_FOR_CALL, CALL_ACTIVE, CALL_CANCELLED, NOT_STARTED,
  PENDING, ACTIVATED, ZOMBIED
}
 

Functions

void grpc_server_register_completion_queue (grpc_server *server, grpc_completion_queue *cq, void *reserved)
 Register a completion queue with the server. More...
 
grpc_servergrpc_server_create_from_filters (const grpc_channel_filter **filters, size_t filter_count, const grpc_channel_args *args)
 
void * grpc_server_register_method (grpc_server *server, const char *method, const char *host)
 Registers a method in the server. More...
 
void grpc_server_start (grpc_server *server)
 Start a server - tells all listeners to start listening. More...
 
void grpc_server_setup_transport (grpc_server *s, grpc_transport *transport, grpc_channel_filter const **extra_filters, size_t num_extra_filters, grpc_mdctx *mdctx, const grpc_channel_args *args)
 
void done_published_shutdown (void *done_arg, grpc_cq_completion *storage)
 
void grpc_server_shutdown_and_notify (grpc_server *server, grpc_completion_queue *cq, void *tag)
 Begin shutting down a server. More...
 
void grpc_server_listener_destroy_done (void *s)
 
void grpc_server_cancel_all_calls (grpc_server *server)
 Cancel all in-progress calls. More...
 
void grpc_server_destroy (grpc_server *server)
 Destroy a server. More...
 
void grpc_server_add_listener (grpc_server *server, void *arg, void(*start)(grpc_server *server, void *arg, grpc_pollset **pollsets, size_t pollset_count), void(*destroy)(grpc_server *server, void *arg))
 
grpc_call_error grpc_server_request_call (grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *initial_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag)
 Request notification of a new call. More...
 
grpc_call_error grpc_server_request_registered_call (grpc_server *server, void *rm, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *initial_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag)
 Request notification of a new pre-registered call. More...
 
const grpc_channel_argsgrpc_server_get_channel_args (grpc_server *server)
 
int grpc_server_has_open_connections (grpc_server *server)
 

Macro Definition Documentation

#define SERVER_FROM_CALL_ELEM (   elem)    (((channel_data *)(elem)->channel_data)->server)

Typedef Documentation

typedef struct call_data call_data
typedef struct channel_data channel_data
typedef struct listener listener
typedef struct shutdown_tag shutdown_tag

Enumeration Type Documentation

enum call_state
Enumerator
CALL_CREATED 
CALL_WAITING_FOR_SEND 
CALL_WAITING_FOR_CONFIG 
CALL_WAITING_FOR_PICK 
CALL_WAITING_FOR_CALL 
CALL_ACTIVE 
CALL_CANCELLED 
NOT_STARTED 
PENDING 
ACTIVATED 
ZOMBIED 
Enumerator
BATCH_CALL 
REGISTERED_CALL 

Function Documentation

void done_published_shutdown ( void *  done_arg,
grpc_cq_completion storage 
)
void grpc_server_add_listener ( grpc_server server,
void *  arg,
void(*)(grpc_server *server, void *arg, grpc_pollset **pollsets, size_t pollset_count)  start,
void(*)(grpc_server *server, void *arg destroy 
)
void grpc_server_cancel_all_calls ( grpc_server server)

Cancel all in-progress calls.

Only usable after shutdown.

grpc_server* grpc_server_create_from_filters ( const grpc_channel_filter **  filters,
size_t  filter_count,
const grpc_channel_args args 
)
void grpc_server_destroy ( grpc_server server)

Destroy a server.

Shutdown must have completed beforehand (i.e. all tags generated by grpc_server_shutdown_and_notify must have been received, and at least one call to grpc_server_shutdown_and_notify must have been made).

const grpc_channel_args* grpc_server_get_channel_args ( grpc_server server)
int grpc_server_has_open_connections ( grpc_server server)
void grpc_server_listener_destroy_done ( void *  s)
void grpc_server_register_completion_queue ( grpc_server server,
grpc_completion_queue cq,
void *  reserved 
)

Register a completion queue with the server.

Must be done for any notification completion queue that is passed to grpc_server_request_*_call and to grpc_server_shutdown_and_notify. Must be performed prior to grpc_server_start.

void* grpc_server_register_method ( grpc_server server,
const char *  method,
const char *  host 
)

Registers a method in the server.

Methods to this (host, method) pair will not be reported by grpc_server_request_call, but instead be reported by grpc_server_request_registered_call when passed the appropriate registered_method (as returned by this function). Must be called before grpc_server_start. Returns NULL on failure.

grpc_call_error grpc_server_request_call ( grpc_server server,
grpc_call **  call,
grpc_call_details details,
grpc_metadata_array request_metadata,
grpc_completion_queue cq_bound_to_call,
grpc_completion_queue cq_for_notification,
void *  tag_new 
)

Request notification of a new call.

Once a call is received, a notification tagged with tag_new is added to cq_for_notification. call, details and request_metadata are updated with the appropriate call information. cq_bound_to_call is bound to call, and batch operation notifications for that call will be posted to cq_bound_to_call. Note that cq_for_notification must have been registered to the server via grpc_server_register_completion_queue.

grpc_call_error grpc_server_request_registered_call ( grpc_server server,
void *  registered_method,
grpc_call **  call,
gpr_timespec deadline,
grpc_metadata_array request_metadata,
grpc_byte_buffer **  optional_payload,
grpc_completion_queue cq_bound_to_call,
grpc_completion_queue cq_for_notification,
void *  tag_new 
)

Request notification of a new pre-registered call.

'cq_for_notification' must have been registered to the server via grpc_server_register_completion_queue.

void grpc_server_setup_transport ( grpc_server s,
grpc_transport transport,
grpc_channel_filter const **  extra_filters,
size_t  num_extra_filters,
grpc_mdctx mdctx,
const grpc_channel_args args 
)
void grpc_server_shutdown_and_notify ( grpc_server server,
grpc_completion_queue cq,
void *  tag 
)

Begin shutting down a server.

After completion, no new calls or connections will be admitted. Existing calls will be allowed to complete. Send a GRPC_OP_COMPLETE event when there are no more calls being serviced. Shutdown is idempotent, and all tags will be notified at once if multiple grpc_server_shutdown_and_notify calls are made. 'cq' must have been registered to this server via grpc_server_register_completion_queue.

void grpc_server_start ( grpc_server server)

Start a server - tells all listeners to start listening.