Skip to content

Commit 8a0b809

Browse files
committed
hndl migration
Signed-off-by: Salil Chandra <[email protected]>
1 parent 224d287 commit 8a0b809

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

cdb2api/cdb2api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, SBUF2 *s, const char *comdb2db
15641564
tok = strtok_r(NULL, " :,", &last);
15651565
if (tok) {
15661566
if (hndl && (strcasecmp(hndl->cluster, "default") == 0)) {
1567-
strncpy(hndl->cluster, tok, sizeof(cdb2_default_cluster) - 1);
1567+
strncpy(hndl->cluster, tok, sizeof(hndl->cluster) - 1);
15681568
} else if (!hndl) {
15691569
strncpy(cdb2_default_cluster, tok, sizeof(cdb2_default_cluster) - 1);
15701570
}
@@ -6628,7 +6628,7 @@ static int comdb2db_get_dbhosts(cdb2_hndl_tp *hndl, const char *comdb2db_name, i
66286628
bindvars[0] = bind_dbname;
66296629
bindvars[1] = bind_cluster;
66306630
bindvars[2] = bind_room;
6631-
char newsql_typestr[128];
6631+
char newsql_typestr[TYPESTR_LEN];
66326632
int is_sockfd = 1;
66336633
int i = 0;
66346634

@@ -6831,7 +6831,7 @@ static int cdb2_dbinfo_query(cdb2_hndl_tp *hndl, const char *type, const char *d
68316831
char valid_hosts[][CDB2HOSTNAME_LEN], int *valid_ports, int *master_node,
68326832
int *num_valid_hosts, int *num_valid_sameroom_hosts)
68336833
{
6834-
char newsql_typestr[128];
6834+
char newsql_typestr[TYPESTR_LEN];
68356835
SBUF2 *sb = NULL;
68366836
int fd = -1;
68376837
int rc = 0; /* Make compilers happy. */

cdb2api/cdb2api_hndl.h

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
#include <sys/types.h>
2727
#include <sys/queue.h>
2828

29-
#define MAX_NODES 128
29+
#define MAX_NODES 48
3030

31-
#define DBNAME_LEN 64
32-
#define TYPE_LEN 64
31+
#define DBNAME_LEN 32
32+
#define TYPE_LEN 32
3333
#define POLICY_LEN 24
3434

35-
#define CDB2HOSTNAME_LEN 128
35+
#define CDB2HOSTNAME_LEN 64
3636

3737
#define MAX_STACK 512 /* Size of call-stack which opened the handle */
3838

@@ -111,7 +111,7 @@ typedef struct cdb2_ssl_sess cdb2_ssl_sess;
111111

112112
struct cdb2_hndl {
113113
char dbname[DBNAME_LEN];
114-
char cluster[64];
114+
char cluster[32];
115115
char type[TYPE_LEN];
116116
char hosts[MAX_NODES][CDB2HOSTNAME_LEN];
117117
uint64_t timestampus; // client query timestamp of first try
@@ -121,6 +121,9 @@ struct cdb2_hndl {
121121
char cached_host[CDB2HOSTNAME_LEN]; /* hostname of a sockpool connection */
122122
int cached_port; /* port of a sockpool connection */
123123
SBUF2 *sb;
124+
int num_set_commands;
125+
int num_set_commands_sent;
126+
char **commands;
124127
int dbnum;
125128
int num_hosts; /* total number of hosts */
126129
int num_hosts_sameroom; /* number of hosts that are in my datacenter (aka room) */
@@ -142,9 +145,9 @@ struct cdb2_hndl {
142145
char *sql;
143146
int ntypes;
144147
int *types;
145-
uint8_t *last_buf;
148+
unsigned char *last_buf;
146149
CDB2SQLRESPONSE *lastresponse;
147-
uint8_t *first_buf;
150+
unsigned char *first_buf;
148151
CDB2SQLRESPONSE *firstresponse;
149152
int error_in_trans;
150153
int client_side_error;
@@ -155,54 +158,72 @@ struct cdb2_hndl {
155158
int snapshot_offset;
156159
int query_no;
157160
int retry_all;
158-
int num_set_commands;
159-
int num_set_commands_sent;
160161
int is_read;
161162
int is_invalid;
162163
int is_rejected;
163164
unsigned long long rows_read;
164165
int read_intrans_results;
165166
int first_record_read;
166-
char **commands;
167167
int ack;
168168
int is_hasql;
169+
int sent_client_info;
170+
void *user_arg;
171+
int api_call_timeout;
172+
int connect_timeout;
173+
int comdb2db_timeout;
174+
int socket_timeout;
175+
int sockpool_send_timeoutms;
176+
int sockpool_recv_timeoutms;
177+
int *gbl_event_version; /* Cached global event version */
178+
cdb2_event *events;
179+
pid_t pid;
169180
int is_admin;
170181
int sockpool_enabled;
171182
int db_default_type_override_env;
172183
int clear_snap_line;
173184
int debug_trace;
174185
int max_retries;
175186
int min_retries;
176-
ssl_mode c_sslmode; /* client SSL mode */
177-
peer_ssl_mode s_sslmode; /* server SSL mode */
178-
int sslerr; /* 1 if unrecoverable SSL error. */
179-
char *sslpath; /* SSL certificates */
187+
/* client SSL mode */
188+
ssl_mode c_sslmode;
189+
/* server SSL mode */
190+
peer_ssl_mode s_sslmode;
191+
/* 1 if unrecoverable SSL error. */
192+
int sslerr;
193+
194+
/* SSL certificate path. When specified, code looks for $sslpath/root.crt,
195+
$sslpath/client.key, $sslpath/client.crt and $sslpath/root.crl, for
196+
root certificate, client certificate, client key, and root CRL, respectively. */
197+
char *sslpath;
198+
199+
/* client certificate. overrides sslpath when specified. */
180200
char *cert;
201+
/* client key. overrides sslpath when specified. */
181202
char *key;
203+
/* root CA certificate. overrides sslpath when specified. */
182204
char *ca;
205+
/* root certificate revocation list (CRL). overrides sslpath when specified. */
183206
char *crl;
184-
int cache_ssl_sess;
207+
208+
/* minimal TLS version. Set it to 0 if we want client and server to negotiate.
209+
The final version will be the minimal version that are mutually understood by
210+
both client and server. Set it to an TLS version (1.2, 1.3, etc.) to override.
211+
Note that if either side does not support the version, handshake will fail. */
185212
double min_tls_ver;
213+
214+
/* 1 if caching ssl sessions (can speed up SSL handshake) */
215+
int cache_ssl_sess;
186216
cdb2_ssl_sess *sess;
187-
int nid_dbname;
188217
/* 1 if it's a newly established session which needs to be cached. */
189218
int newsess;
219+
220+
/* X509 attribute to check database name against */
221+
int nid_dbname;
190222
struct context_messages context_msgs;
191223
char *env_tz;
192-
int sent_client_info;
193224
char stack[MAX_STACK];
194225
int send_stack;
195-
void *user_arg;
196-
int *gbl_event_version; /* Cached global event version */
197-
int api_call_timeout;
198-
int connect_timeout;
199-
int comdb2db_timeout;
200-
int socket_timeout;
201-
int sockpool_send_timeoutms;
202-
int sockpool_recv_timeoutms;
203226
int request_fp; /* 1 if requesting the fingerprint; 0 otherwise. */
204-
cdb2_event *events;
205-
pid_t pid;
206227
// Protobuf allocator data used only for row data i.e. lastresponse
207228
ProtobufCAllocator s_allocator;
208229
void *protobuf_data;
@@ -217,5 +238,4 @@ struct cdb2_hndl {
217238
struct cdb2_stmt_types *stmt_types;
218239
RETRY_CALLBACK retry_clbk;
219240
};
220-
221241
#endif

tests/tools/cdb2api_unit.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include <bb_oscompat.h>
2525
#include <cdb2api.c>
2626

27-
#define CDB2HOSTNAME_LEN 128
28-
2927
void test_is_sql_read()
3028
{
3129
assert(is_sql_read(NULL) == -1);

0 commit comments

Comments
 (0)