Mercurial > hg > nginx-quic
annotate src/mysql/ngx_mysql.h @ 5058:f25d0bbc4392 stable-1.2
Merge of r5004, r5019-r5025: ssl fixes.
*) SSL: speedup loading of configs with many ssl servers. The patch
saves one EC_KEY_generate_key() call per server{} block by informing
OpenSSL about SSL_OP_SINGLE_ECDH_USE we are going to use before
the SSL_CTX_set_tmp_ecdh() call.
For a configuration file with 10k simple server{} blocks with SSL
enabled this change reduces startup time from 18s to 5s on a slow
test box here.
*) SSL: removed conditions that always hold true.
*) SSL: resetting of flush flag after the data was written. There is
no need to flush next chunk of data if it does not contain a buffer
with the flush or last_buf flags set.
*) SSL: preservation of flush flag for buffered data. Previously,
if SSL buffer was not sent we lost information that the data
must be flushed.
*) SSL: calculation of buffer size moved closer to its usage.
No functional changes.
*) SSL: avoid calling SSL_write() with zero data size. According to
documentation, calling SSL_write() with num=0 bytes to be sent
results in undefined behavior.
We don't currently call ngx_ssl_send_chain() with empty chain and
buffer. This check handles the case of a chain with total data size
that is a multiple of NGX_SSL_BUFSIZE, and with the special buffer
at the end.
In practice such cases resulted in premature connection close and
critical error "SSL_write() failed (SSL:)" in the error log.
*) SSL: take into account data in the buffer while limiting output.
In some rare cases this can result in a more smooth sending rate.
*) SSL: fixed ngx_ssl_handshake() with level-triggered event methods.
Missing calls to ngx_handle_write_event() and ngx_handle_read_event()
resulted in a CPU hog during SSL handshake if an level-triggered event
method (e.g. select) was used.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 11 Feb 2013 15:12:06 +0000 |
parents | d620f497c50f |
children |
rev | line source |
---|---|
645 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
645 | 5 */ |
6 | |
7 | |
8 #ifndef _NGX_MYSQL_H_INCLUDED_ | |
9 #define _NGX_MYSQL_H_INCLUDED_ | |
10 | |
11 | |
12 #include <ngx_config.h> | |
13 #include <ngx_core.h> | |
14 #include <ngx_event.h> | |
653 | 15 #include <ngx_event_connect.h> |
16 | |
17 | |
18 typedef struct ngx_mysql_s ngx_mysql_t; | |
19 | |
20 typedef void (*ngx_mysql_handler_pt)(ngx_mysql_t *m); | |
645 | 21 |
22 | |
653 | 23 struct ngx_mysql_s { |
645 | 24 ngx_peer_connection_t peer; |
653 | 25 |
26 ngx_buf_t *buf; | |
27 ngx_pool_t *pool; | |
28 | |
29 ngx_str_t *login; | |
30 ngx_str_t *passwd; | |
31 ngx_str_t *database; | |
32 | |
33 ngx_str_t query; | |
34 | |
35 ngx_uint_t pktn; | |
36 | |
37 ngx_mysql_handler_pt handler; | |
38 void *data; | |
39 ngx_int_t state; | |
40 | |
41 }; | |
42 | |
43 | |
44 #define NGX_MYSQL_CMDPKT_LEN 5 | |
645 | 45 |
46 | |
47 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED && 0) | |
48 | |
653 | 49 #define ngx_m16toh(n) (*(uint32_t *) n & 0x0000ffff) |
50 #define ngx_m24toh(n) (*(uint32_t *) n & 0x00ffffff) | |
51 #define ngx_m32toh(n) *(uint32_t *) n | |
52 | |
53 #define ngx_htom16(n, m) *(uint16_t *) n = (uint16_t) ((m) & 0xffff) | |
54 | |
55 #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
56 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
57 (n)[2] = (u_char) (((m) >> 16) & 0xff) | |
58 | |
59 #define ngx_htom32(n, m) *(uint32_t *) (n) = (m) | |
645 | 60 |
61 #else | |
62 | |
653 | 63 #define ngx_m16toh(n) (n[0] | n[1] << 8) |
64 #define ngx_m24toh(n) (n[0] | n[1] << 8 | n[2] << 16) | |
65 #define ngx_m32toh(n) (n[0] | n[1] << 8 | n[2] << 16 | n[3] << 24) | |
66 | |
67 #define ngx_htom16(n, m) (n)[0] = (u_char) (m); (n)[1] = (u_char) ((m) >> 8) | |
68 | |
69 #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
70 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
71 (n)[2] = (u_char) (((m) >> 16) & 0xff) | |
72 | |
73 #define ngx_htom32(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
74 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
75 (n)[2] = (u_char) (((m) >> 16) & 0xff); \ | |
76 (n)[3] = (u_char) (((m) >> 24) & 0xff) | |
645 | 77 |
78 #endif | |
79 | |
80 | |
653 | 81 ngx_int_t ngx_mysql_connect(ngx_mysql_t *m); |
82 ngx_int_t ngx_mysql_query(ngx_mysql_t *m); | |
83 | |
84 | |
645 | 85 #endif /* _NGX_MYSQL_H_INCLUDED_ */ |