当前位置: 首页>>代码示例>>C++>>正文


C++ request_destroy函数代码示例

本文整理汇总了C++中request_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ request_destroy函数的具体用法?C++ request_destroy怎么用?C++ request_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了request_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process_message

static int
process_message(SoupMessage *msg)
{
    struct request *req;
    char *data;
    GTimer *timer;
    gulong microsecs;

    timer = g_timer_new();
    g_timer_start(timer);

    req = request_new(msg->request_body->data);
    if (!req)
        return 1;

    data = request_response(req);
    if (!data)
        return 1;

    request_destroy(req);

    soup_message_set_response(msg, "application/json",
                              SOUP_MEMORY_TAKE, data, strlen(data));
    soup_message_set_status(msg, SOUP_STATUS_OK);

    g_timer_stop(timer);
    g_print("Time elapsed: %f\n", g_timer_elapsed(timer, &microsecs));
    g_timer_destroy(timer);
    return 0;
}
开发者ID:ehostunreach,项目名称:fetch-complete,代码行数:30,代码来源:server.c

示例2: domain_export

static command_status_t domain_export(COMMAND_ARGS)
{
    xmlDocPtr doc;
    request_t *req;
    xmlNodePtr root;
    bool request_success;
    domain_record_argument_t *args;

    USED(mainopts);
    args = (domain_record_argument_t *) arg;
    assert(NULL != args->domain);

    req = request_new(REQUEST_FLAG_SIGN, HTTP_GET, NULL, error, API_BASE_URL "/domain/zone/%s/export", args->domain);
    REQUEST_XML_RESPONSE_WANTED(req); // we ask XML instead of JSON else we have to parse invalid json document or to unescape characters
    if ((request_success = request_execute(req, RESPONSE_XML, (void **) &doc, error))) {
        if (NULL != (root = xmlDocGetRootElement(doc))) {
            xmlChar *content;

            content = xmlNodeGetContent(root);
            puts((const char *) content);
            xmlFree(content);
        }
        request_success = NULL != root;
        xmlFreeDoc(doc);
    }
    request_destroy(req);

    return request_success ? COMMAND_SUCCESS : COMMAND_FAILURE;
}
开发者ID:carriercomm,项目名称:ovh-cli-1,代码行数:29,代码来源:domain.c

示例3: test_teardown

static void
test_teardown(void)
{
    buf_destroy(&buf);
    response_destroy(&rsp);
    request_destroy(&req);
}
开发者ID:huayl,项目名称:pelikan,代码行数:7,代码来源:check_redis.c

示例4: dnssec_status

static command_status_t dnssec_status(COMMAND_ARGS)
{
    request_t *req;
    bool request_success;
    json_document_t *doc;
    domain_record_argument_t *args;

    USED(mainopts);
    args = (domain_record_argument_t *) arg;
    assert(NULL != args->domain);
    req = request_new(REQUEST_FLAG_SIGN, HTTP_GET, NULL, error, API_BASE_URL "/domain/zone/%s/dnssec", args->domain);
    request_success = request_execute(req, RESPONSE_JSON, (void **) &doc, error);
    request_destroy(req);
    if (request_success) {
        json_value_t root, v;

        root = json_document_get_root(doc);
#if 0
        // for translations, do not remove
        _("enabled")
        _("disabled")
        _("enableInProgress")
        _("disableInProgress")
#endif
        json_object_get_property(root, "status", &v);
        puts(_(json_get_string(v)));
        json_document_destroy(doc);
    }

    return request_success ? COMMAND_SUCCESS : COMMAND_FAILURE;
}
开发者ID:carriercomm,项目名称:ovh-cli-1,代码行数:31,代码来源:domain.c

示例5: mock_server_receives_query

request_t *
mock_server_receives_query (mock_server_t *server,
                            const char *ns,
                            mongoc_query_flags_t flags,
                            uint32_t skip,
                            uint32_t n_return,
                            const char *query_json,
                            const char *fields_json)
{
   request_t *request;

   request = mock_server_receives_request (server);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          skip,
                                          n_return,
                                          query_json,
                                          fields_json,
                                          false)) {
      request_destroy (request);
      return NULL;
   }

   return request;
}
开发者ID:Zhangli88,项目名称:mongo-c-driver,代码行数:27,代码来源:mock-server.c

示例6: mock_server_receives_query

request_t *
mock_server_receives_query (mock_server_t *server,
                            const char *ns,
                            mongoc_query_flags_t flags,
                            uint32_t skip,
                            uint32_t n_return,
                            const char *query_json,
                            const char *fields_json)
{
   sync_queue_t *q;
   request_t *request;

   q = mock_server_get_queue (server);
   request = (request_t *) q_get (q, server->request_timeout_msec);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          skip,
                                          n_return,
                                          query_json,
                                          fields_json,
                                          false)) {
      request_destroy (request);
      return NULL;
   }

   return request;
}
开发者ID:arjuns123,项目名称:mongo-c-driver,代码行数:29,代码来源:mock-server.c

示例7: proposer_ack_request

/**
 * proposer_ack_request - Dispatch a request as a decree.
 */
int
proposer_ack_request(struct paxos_header *hdr, msgpack_object *o)
{
  struct paxos_request *req;
  struct paxos_acceptor *acc;

  // Allocate a request and unpack into it.
  req = g_malloc0(sizeof(*req));
  paxos_request_unpack(req, o);

  // The requester overloads ph_inst to the ID of the acceptor it believes
  // to be the proposer.  If the requester has a live connection to us but
  // thinks that a lower-ranked acceptor is the proposer, kill them for
  // having inconsistent state.
  //
  // It is possible that a higher-ranked acceptor is identified as the
  // proposer.  This should occur only in the case that we are preparing but
  // have lost our connection to the true proposer; in this case we will defer
  // our decree until after our prepare.  If we indeed are not the proposer,
  // our prepare will fail, and we will be redirected at that point.
  if (hdr->ph_inum > pax->self_id) {
    acc = acceptor_find(&pax->alist, req->pr_val.pv_reqid.id);
    request_destroy(req);
    return proposer_decree_part(acc, 1);
  }

  // Add it to the request cache if needed.
  if (request_needs_cached(req->pr_val.pv_dkind)) {
    request_insert(&pax->rcache, req);
  }

  return proposer_decree_request(req);
}
开发者ID:flowerhack,项目名称:motmot,代码行数:36,代码来源:paxos_request.c

示例8: fetch_domains

static command_status_t fetch_domains(domain_set_t *ds, bool force, error_t **error)
{
    if (!ds->uptodate || force) {
        request_t *req;
        bool request_success;
        json_document_t *doc;

        req = request_new(REQUEST_FLAG_SIGN, HTTP_GET, NULL, error, API_BASE_URL "/domain");
        request_success = request_execute(req, RESPONSE_JSON, (void **) &doc, error);
        request_destroy(req);
        if (request_success) {
            Iterator it;
            json_value_t root;

            root = json_document_get_root(doc);
            hashtable_clear(ds->domains);
            json_array_to_iterator(&it, root);
            for (iterator_first(&it); iterator_is_valid(&it); iterator_next(&it)) {
                json_value_t v;

                v = (json_value_t) iterator_current(&it, NULL);
                hashtable_put(ds->domains, 0, json_get_string(v), domain_new(), NULL); // ds->domains has strdup as key_duper, don't need to strdup it ourself
            }
            iterator_close(&it);
            ds->uptodate = TRUE;
            json_document_destroy(doc);
        } else {
            return COMMAND_FAILURE;
        }
    }

    return COMMAND_SUCCESS;
}
开发者ID:carriercomm,项目名称:ovh-cli-1,代码行数:33,代码来源:domain.c

示例9: request_api_deinitialize

void request_api_deinitialize()
{
    pthread_mutex_destroy(&requestStackMutexG);

    while (requestStackCountG--) {
        request_destroy(requestStackG[requestStackCountG]);
    }
}
开发者ID:hjiawei,项目名称:libs3,代码行数:8,代码来源:request.c

示例10: hangup

static bool
hangup (request_t *request,
        void *ctx)
{
   mock_server_hangs_up (request);
   request_destroy (request);
   return true;
}
开发者ID:Zhangli88,项目名称:mongo-c-driver,代码行数:8,代码来源:mock-server.c

示例11: get_domain_records

static bool get_domain_records(const char *domain, domain_t **d, bool force, error_t **error)
{
    domain_set_t *ds;
    bool request_success;

    *d = NULL;
    FETCH_ACCOUNT_DOMAINS(ds);
    request_success = TRUE;
    // TODO: hashtable_clear((*d)->records) if force
    if (!hashtable_get(ds->domains, domain, d) || !(*d)->uptodate || force) {
        request_t *req;
        json_document_t *doc;

        if (NULL == *d) {
            *d = domain_new();
            hashtable_put(ds->domains, 0, domain, *d, NULL);
        }
        req = request_new(REQUEST_FLAG_SIGN, HTTP_GET, NULL, error, API_BASE_URL "/domain/zone/%s/record", domain);
        request_success = request_execute(req, RESPONSE_JSON, (void **) &doc, error);
        request_destroy(req);
        // result
        if (request_success) {
            Iterator it;
            json_value_t root;

            root = json_document_get_root(doc);
            json_array_to_iterator(&it, root);
            for (iterator_first(&it); request_success && iterator_is_valid(&it); iterator_next(&it)) {
                json_value_t v;
                json_document_t *doc;

                v = (json_value_t) iterator_current(&it, NULL);
                req = request_new(REQUEST_FLAG_SIGN, HTTP_GET, NULL, error, API_BASE_URL "/domain/zone/%s/record/%u", domain, json_get_integer(v));
                request_success = request_execute(req, RESPONSE_JSON, (void **) &doc, error);
                request_destroy(req);
                // result
                parse_record((*d)->records, doc);
            }
            iterator_close(&it);
            json_document_destroy(doc);
            (*d)->uptodate = TRUE;
        }
    }

    return request_success ? COMMAND_SUCCESS : COMMAND_FAILURE;
}
开发者ID:carriercomm,项目名称:ovh-cli-1,代码行数:46,代码来源:domain.c

示例12: _test_find_command

static void
_test_find_command (const mongoc_uri_t  *uri,
                    mock_server_t       *server,
                    const char          *query_in,
                    mongoc_read_prefs_t *read_prefs,
                    mongoc_query_flags_t expected_find_cmd_query_flags,
                    const char          *expected_find_cmd)
{
   mongoc_client_t *client;
   mongoc_collection_t *collection;
   mongoc_cursor_t *cursor;
   const bson_t *doc;
   bson_t b = BSON_INITIALIZER;
   future_t *future;
   request_t *request;

   client = mongoc_client_new_from_uri (uri);
   collection = mongoc_client_get_collection (client, "test", "test");
   mongoc_collection_set_read_prefs (collection, read_prefs);

   cursor = mongoc_collection_find (collection,
                                    MONGOC_QUERY_NONE,
                                    0,
                                    1,
                                    0,
                                    tmp_bson (query_in),
                                    NULL,
                                    read_prefs);

   future = future_cursor_next (cursor, &doc);

   request = mock_server_receives_command (
      server,
      "test",
      expected_find_cmd_query_flags,
      expected_find_cmd);

   mock_server_replies (request,
                        MONGOC_REPLY_NONE,    /* flags */
                        0,                    /* cursorId */
                        0,                    /* startingFrom */
                        1,                    /* numberReturned */
                        "{'ok': 1,"
                        " 'cursor': {"
                        "    'id': 0,"
                        "    'ns': 'db.collection',"
                        "    'firstBatch': [{'a': 1}]}}");

   /* mongoc_cursor_next returned true */
   assert (future_get_bool (future));

   request_destroy (request);
   future_destroy (future);
   mongoc_cursor_destroy (cursor);
   mongoc_collection_destroy (collection);
   mongoc_client_destroy (client);
   bson_destroy (&b);
}
开发者ID:3rf,项目名称:mongo-c-driver,代码行数:58,代码来源:test-mongoc-read-prefs.c

示例13: _test_op_msg_direct_connection

/* direct connection to a secondary requires read pref primaryPreferred to
 * avoid "not master" error from server */
static void
_test_op_msg_direct_connection (bool is_mongos,
                                test_op_msg_direct_fn_t fn,
                                const char *expected_cmd)
{
   mock_server_t *server;
   mongoc_client_t *client;
   mongoc_collection_t *collection;
   mongoc_read_prefs_t *prefs = NULL;
   mongoc_cursor_t *cursor;
   const bson_t *doc;
   bson_t *cmd;
   future_t *future;
   request_t *request;
   const char *reply;
   int i;

   if (is_mongos) {
      server = mock_mongos_new (WIRE_VERSION_OP_MSG);
   } else {
      server = mock_server_with_autoismaster (WIRE_VERSION_OP_MSG);
   }

   mock_server_auto_endsessions (server);

   mock_server_run (server);
   client = mongoc_client_new_from_uri (mock_server_get_uri (server));
   collection = mongoc_client_get_collection (client, "db", "collection");

   for (i = 0; i < 2; i++) {
      if (i == 1) {
         /* user-supplied read preference primary makes no difference */
         prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY);
      }

      cursor = fn (collection, prefs);
      future = future_cursor_next (cursor, &doc);
      cmd = tmp_bson (expected_cmd);
      request = mock_server_receives_msg (server, 0, cmd);
      reply = "{'ok': 1,"
              " 'cursor': {"
              "    'id': 0,"
              "    'ns': 'db.collection',"
              "    'firstBatch': [{'a': 1}]}}";

      mock_server_replies_simple (request, reply);
      BSON_ASSERT (future_get_bool (future));
      future_destroy (future);
      request_destroy (request);
      mongoc_cursor_destroy (cursor);
      mongoc_read_prefs_destroy (prefs); /* null ok */
   }

   mongoc_collection_destroy (collection);
   mongoc_client_destroy (client);
   mock_server_destroy (server);
}
开发者ID:acmorrow,项目名称:mongo-c-driver,代码行数:59,代码来源:test-mongoc-read-prefs.c

示例14: do_server_request

static void
do_server_request(struct server *sv, int connfd)
{
	int ret;
	struct request *rq;
	struct file_data *data;
	data = file_data_init();	
	rq = request_init(connfd, data);
	
	if (!rq) {
		file_data_free(data);
		return;
	}
	
	if(cache_active ==1){
		pthread_mutex_lock( &conditionMutex); 
		struct hash_node *cache_stored; 
		cache_stored= cache_lookup(data->file_name);
		
		if(cache_stored!=NULL){  // check if it populated in the cache{
			data->file_buf = Malloc(cache_stored->data->file_size);
			strncpy(data->file_buf, cache_stored->data->file_buf, cache_stored->data->file_size);
			data->file_size =cache_stored->data->file_size;
		}
		else{
		/* reads file, 
	 	* fills data->file_buf with the file contents,
	 	* data->file_size with file size. */
	 	pthread_mutex_unlock( &conditionMutex ); 
		ret = request_readfile(rq);
		pthread_mutex_lock( &conditionMutex ); 
		// need to renew the cache
			if(data->file_size<max_cache){
				if(data->file_size <=(max_cache-cache_current_size) ){
					cache_insert(data);
				}
				else{
					cache_evict(data->file_size);
					cache_insert(data);
				}
			}
		}
		pthread_mutex_unlock( &conditionMutex ); 


	}	
	else{
		ret = request_readfile(rq);
		if (!ret)
		goto out;
	}
	/* sends file to client */
	request_sendfile(rq);
out:
	request_destroy(rq);
	file_data_free(data);
}
开发者ID:miki2112,项目名称:multi_threaded_web_server,代码行数:57,代码来源:server_thread.c

示例15: record_add

// ./ovh domain domain.ext record toto add www type CNAME
// TODO: ttl (optionnal)
static command_status_t record_add(COMMAND_ARGS)
{
    bool request_success;
    json_document_t *doc;
    domain_record_argument_t *args;

    USED(mainopts);
    args = (domain_record_argument_t *) arg;
    assert(NULL != args->domain);
    assert(NULL != args->record);
    {
        json_document_t *reqdoc;

        // data
        {
            json_value_t root;

            reqdoc = json_document_new();
            root = json_object();
            json_object_set_property(root, "target", json_string(args->value));
            json_object_set_property(root, "fieldType", json_string(domain_record_types[args->type]));
//             if ('\0' != *subdomain)
                json_object_set_property(root, "subDomain", json_string(args->record));
            json_document_set_root(reqdoc, root);
        }
        // request
        {
            request_t *req;

            req = request_new(REQUEST_FLAG_SIGN | REQUEST_FLAG_JSON, HTTP_POST, reqdoc, error, API_BASE_URL "/domain/zone/%s/record", args->domain);
            request_success = request_execute(req, RESPONSE_JSON, (void **) &doc, error);
            request_destroy(req);
            json_document_destroy(reqdoc);
        }
    }
    // result
    if (request_success) {
        domain_t *d;
        ht_hash_t h;
        domain_set_t *ds;

        d = NULL;
        ds = NULL;
        account_current_get_data(MODULE_NAME, (void **) &ds);
        assert(NULL != ds);
        h = hashtable_hash(ds->domains, args->domain);
        if (!hashtable_quick_get(ds->domains, h, args->domain, &d)) {
            d = domain_new();
            hashtable_quick_put(ds->domains, 0, h, args->domain, d, NULL);
        }
        parse_record(d->records, doc);
        ask_for_refresh(RELAY_COMMAND_ARGS);
    }

    return request_success ? COMMAND_SUCCESS : COMMAND_FAILURE;
}
开发者ID:carriercomm,项目名称:ovh-cli-1,代码行数:58,代码来源:domain.c


注:本文中的request_destroy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。