Browse Source

#9 add (c), minor fixes

tags/v0.0.4
Vasiliy Soshnikov 4 years ago
parent
commit
6f4fe17849
5 changed files with 154 additions and 15 deletions
  1. 9
    0
      AUTHORS
  2. 31
    0
      LICENSE
  3. 36
    6
      ngx_http_tnt_module.c
  4. 43
    5
      tp_transcode.c
  5. 35
    4
      tp_transcode.h

+ 9
- 0
AUTHORS View File

@@ -0,0 +1,9 @@
Tarantool Nginx upstream module is a collective effort, and incorporates
many contributions from the community.

Below follows a list of people, who contributed their code.

Vasily Soshnikov, Andrew Drozdow, E. Blih, Konstantin Osipov

NOTE: If you can commit a change to this list, please do not hesitate
to add your name to it.

+ 31
- 0
LICENSE View File

@@ -0,0 +1,31 @@
Copyright (C) 2015 Tarantool AUTHORS:
please see AUTHORS file.

/*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

+ 36
- 6
ngx_http_tnt_module.c View File

@@ -1,5 +1,33 @@
/*
* Copyright (C)
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (C) 2015 Tarantool AUTHORS:
* please see AUTHORS file.
*/

#include <ngx_config.h>
@@ -47,7 +75,7 @@ typedef struct {
enum ctx_state state;
ngx_buf_t *in_err, *tp_cache;
ssize_t rest, payload_size;
int8_t rest_batch_size, batch_size;
int rest_batch_size, batch_size;
ngx_int_t greeting:1;

} ngx_http_tnt_ctx_t;
@@ -723,10 +751,12 @@ ngx_http_tnt_reset_ctx(ngx_http_tnt_ctx_t *ctx)

ctx->in_err = ctx->tp_cache = NULL;

ctx->rest =
ctx->payload_size =
ctx->rest_batch_size =
ctx->batch_size =
ctx->rest = 0;
ctx->payload_size = 0;

ctx->rest_batch_size = 0;
ctx->batch_size = 0;

ctx->greeting = 0;
}


+ 43
- 5
tp_transcode.c View File

@@ -1,10 +1,48 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
/*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (C) 2015 Tarantool AUTHORS:
* please see AUTHORS file.
*/

#if !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1
#endif // !__STDC_FORMAT_MACROS
#include "tp_transcode.h"

#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>

#define MP_SOURCE 1
#include <tarantool-c/src/tp.h>
#include "tp_transcode.h"

#if defined DEBUG
#define dd(...) fprintf(stderr, __VA_ARGS__)
@@ -344,9 +382,9 @@ yajl_map_key(void *ctx, const unsigned char * key, size_t len)

s_ctx->stage = WAIT_NEXT;

if (mp_unlikely(s_ctx->tc->batch_size == 255)) {
if (mp_unlikely(s_ctx->tc->batch_size > 16384)) {
say_error(s_ctx, -32600,
"too large batch, max allowed 254 calls per request");
"too large batch, max allowed 16384 calls per request");
return 0;
}


+ 35
- 4
tp_transcode.h View File

@@ -1,10 +1,41 @@
/*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (C) 2015 Tarantool AUTHORS:
* please see AUTHORS file.
*/

#ifndef TP_TRANSCODE_H_INCLUDED
#define TP_TRANSCODE_H INCLUDED

#include <assert.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
@@ -71,7 +102,7 @@ typedef struct tp_transcode {
char *errmsg;
int errcode;

uint8_t batch_size;
int batch_size;
} tp_transcode_t;

/** Returns codes

Loading…
Cancel
Save