31 #include <sys/types.h> 38 #include <sys/ioctl.h> 40 #include <sys/socket.h> 41 #include <netinet/in.h> 48 #include <sys/select.h> 52 #include <sys/filio.h> 68 #if defined(SERVER_MODE) 80 #if defined (SERVER_MODE) || defined (SA_MODE) 88 #if !defined (SERVER_MODE) 89 #define pthread_mutex_init(a, b) 90 #define pthread_mutex_destroy(a) 91 #define pthread_mutex_lock(b) 0 92 #define pthread_mutex_unlock(a) 96 #define INITIAL_IP_NUM 16 99 typedef char *caddr_t;
103 #define CSS_TRUNCATE_BUFFER_SIZE 512 105 #if !defined (SERVER_MODE) 113 #define CSS_VECTOR_SIZE (1024 * 64) 115 #if defined(SERVER_MODE) 116 #define CSS_NUM_INTERNAL_VECTOR_BUF 20 117 static char *css_Vector_buffer =
NULL;
118 static char *css_Vector_buffer_piece[CSS_NUM_INTERNAL_VECTOR_BUF] = { 0 };
119 static int css_Vector_buffer_occupied_flag[CSS_NUM_INTERNAL_VECTOR_BUF] = { 0 };
121 static pthread_mutex_t css_Vector_buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
122 static pthread_cond_t css_Vector_buffer_cond = PTHREAD_COND_INITIALIZER;
124 static char css_Vector_buffer[CSS_VECTOR_SIZE];
135 const char *buff3,
int len3);
137 const char *buff3,
int len3,
const char *buff4,
int len4);
138 #if !defined(SERVER_MODE) 140 const char *buff3,
int len3,
const char *buff4,
int len4,
const char *buff5,
int len5);
143 const char *buff3,
int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
144 const char *buff6,
int len6);
145 #if !defined(SERVER_MODE) 147 const char *buff3,
int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
148 const char *buff6,
int len6,
const char *buff7,
int len7);
151 const char *buff3,
int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
152 const char *buff6,
int len6,
const char *buff7,
int len7,
const char *buff8,
int len8);
153 #if defined(ENABLE_UNUSED_FUNCTION) 154 static int css_net_send_large_data_with_arg (
CSS_CONN_ENTRY * conn,
const char *header_buffer,
int header_len,
155 NET_HEADER * header_array,
const char **data_array,
int num_array);
157 #if defined(SERVER_MODE) 158 static char *css_trim_str (
char *str);
161 #if !defined (CS_MODE) 167 const char *user_name);
171 #if !defined(SERVER_MODE) 176 static char user_name[
L_cuserid] = {
'\0' };
183 if (conn !=
NULL && conn->get_tran_index () != -1)
187 strcpy (user_name,
"");
192 strcpy (host_name,
"???");
197 *client_user_name = user_name;
198 *client_host_name = host_name;
200 tran_index = conn->get_tran_index ();
214 #elif defined(WINDOWS) 227 const char *client_prog_name;
229 int error, tran_index = -1;
233 if (conn !=
NULL && conn->get_tran_index () != -1)
236 client_host_name, client_pid);
239 tran_index = conn->get_tran_index ();
247 #if defined(WINDOWS) || !defined(SERVER_MODE) 251 const char *client_user_name;
252 const char *client_host_name;
254 int client_tranindex;
258 if (client_tranindex != -1)
261 client_user_name, client_host_name, client_pid);
266 #if defined (ENABLE_UNUSED_FUNCTION) 282 css_net_send_no_block (
SOCKET fd,
const char *buffer,
int size)
286 unsigned long noblock = 1, block = 0;
289 rc = ioctlsocket (fd, FIONBIO, &noblock);
290 if (rc == SOCKET_ERROR)
295 for (total = 0; total < 2 * size; total +=
rc)
297 rc = send (fd, buffer, size, 0);
300 winsock_error = WSAGetLastError ();
301 if (rc < 0 && winsock_error != WSAEWOULDBLOCK && winsock_error != WSAEINTR)
312 rc = ioctlsocket (fd, FIONBIO, &block);
320 int rc, noblock = 1, block = 0, total = 0;
322 rc = ioctl (fd, FIONBIO, (caddr_t) (&noblock));
328 for (total = 0; total < 2 * size; total +=
rc)
331 rc = send (fd, buffer, size, 0);
334 if (rc <= 0 && errno != EWOULDBLOCK && errno != EINTR && errno != EAGAIN && errno != EACCES)
345 rc = ioctl (fd, FIONBIO, (caddr_t) (&block));
368 #if defined (WINDOWS) 371 struct pollfd po[1] = { {0, 0, 0} };
389 #if !defined (WINDOWS) 391 po[0].events = POLLIN;
393 n = poll (po, 1, timeout);
404 #if !defined (SERVER_MODE) 417 if (po[0].revents & POLLERR || po[0].revents & POLLHUP)
428 n = recv (fd, ptr, nleft, 0);
437 #if !defined(WINDOWS) 447 winsock_error = WSAGetLastError ();
451 if (winsock_error == WSAENOBUFS)
456 if (winsock_error == WSAEINTR)
461 #if !defined (SERVER_MODE) 474 return (nbytes - nleft);
492 int nbytes, buf_size;
496 if (len <= SSIZEOF (temp_buffer))
502 buf_size = SSIZEOF (temp_buffer);
505 nbytes =
css_readn (fd, temp_buffer, buf_size, -1);
514 if (nbytes < buf_size)
544 time_unit = timeout > 5000 ? 5000 : timeout;
550 nbytes =
css_readn (fd, (
char *) &templen,
sizeof (
int), time_unit);
553 if (errno == ETIMEDOUT && timeout > elapsed)
555 #if defined (CS_MODE) && !defined (WINDOWS) 571 elapsed += time_unit;
576 if (nbytes !=
sizeof (
int))
589 templen =
ntohl (templen);
590 if (templen > *maxlen)
592 length_to_read = *maxlen;
596 length_to_read = templen;
600 nbytes =
css_readn (fd, buffer, length_to_read, timeout);
601 if (nbytes < length_to_read)
614 if (nbytes && (templen > nbytes))
620 if (nbytes != templen)
649 css_writen (
SOCKET fd,
char *ptr,
int nbytes)
651 int num_retries = 0, sleep_nsecs = 1;
659 nwritten = send (fd, ptr, nleft, 0);
664 winsock_error = WSAGetLastError ();
665 if (winsock_error == WSAEINTR)
678 return (nbytes - nleft);
681 #if defined(SERVER_MODE) 689 alloc_vector_buffer (
void)
692 #ifdef VECTOR_IO_TUNE 698 if (css_Vector_buffer ==
NULL)
700 r = pthread_cond_init (&css_Vector_buffer_cond,
NULL);
701 css_Vector_buffer = (
char *) malloc (CSS_NUM_INTERNAL_VECTOR_BUF * CSS_VECTOR_SIZE);
703 if (css_Vector_buffer ==
NULL)
707 (
size_t) (CSS_NUM_INTERNAL_VECTOR_BUF * CSS_VECTOR_SIZE));
711 for (i = 0; i < CSS_NUM_INTERNAL_VECTOR_BUF; i++)
713 css_Vector_buffer_piece[
i] = css_Vector_buffer + i * CSS_VECTOR_SIZE;
719 for (i = 0; i < CSS_NUM_INTERNAL_VECTOR_BUF; i++)
721 if (css_Vector_buffer_occupied_flag[i] == 0)
723 css_Vector_buffer_occupied_flag[
i] = 1;
725 #ifdef VECTOR_IO_TUNE 728 fprintf (stderr,
"Thread[%d] looped ****** %d ***** to alloc buffer\n", GetCurrentThreadId (),
737 #ifdef VECTOR_IO_TUNE 741 r = pthread_cond_wait (&css_Vector_buffer_cond, &css_Vector_buffer_mutex);
746 #if defined(SERVER_MODE) 753 free_vector_buffer (
int index)
759 css_Vector_buffer_occupied_flag[
index] = 0;
760 r = pthread_cond_signal (&css_Vector_buffer_cond);
782 int i, total_size, available, amount,
rc;
785 #if defined(SERVER_MODE) 799 for (i = 0; i < *len; i++)
801 total_size += (*vec)[
i].iov_len;
804 #if defined(SERVER_MODE) 805 vb_index = alloc_vector_buffer ();
806 dest = css_Vector_buffer_piece[vb_index];
808 dest = css_Vector_buffer;
810 available = CSS_VECTOR_SIZE;
812 for (i = 0; i < *len; i++)
814 src = (*vec)[
i].iov_base;
815 amount = (*vec)[
i].iov_len;
819 while (amount > available)
821 memcpy (dest, src, available);
823 #if defined(SERVER_MODE) 824 rc = css_writen (fd, css_Vector_buffer_piece[vb_index], CSS_VECTOR_SIZE);
826 rc = css_writen (fd, css_Vector_buffer, CSS_VECTOR_SIZE);
828 if (rc != CSS_VECTOR_SIZE)
835 #if defined(SERVER_MODE) 836 dest = css_Vector_buffer_piece[vb_index];
838 dest = css_Vector_buffer;
840 available = CSS_VECTOR_SIZE;
846 memcpy (dest, src, amount);
853 if (available < CSS_VECTOR_SIZE)
855 amount = CSS_VECTOR_SIZE - available;
856 #if defined(SERVER_MODE) 857 rc = css_writen (fd, css_Vector_buffer_piece[vb_index], amount);
859 rc = css_writen (fd, css_Vector_buffer, amount);
867 #if defined(SERVER_MODE) 868 free_vector_buffer (vb_index);
876 #if defined(SERVER_MODE) 877 free_vector_buffer (vb_index);
896 struct pollfd po[1] = { {0, 0, 0} };
905 if (bytes_written > 0)
909 for (i = 0; i < *len; i++)
911 if ((*vec)[i].iov_len <= (
size_t) bytes_written)
913 bytes_written -= (*vec)[
i].iov_len;
920 (*vec)[
i].iov_len -= bytes_written;
921 (*vec)[
i].iov_base = ((
char *) ((*vec)[
i].iov_base)) + bytes_written;
930 po[0].events = POLLOUT;
932 n = poll (po, 1, timeout);
951 if (po[0].revents & POLLERR || po[0].revents & POLLHUP)
955 (po[0].revents & POLLERR ?
"POLLERR" :
"POLLHUP"), strerror (errno));
961 n = writev (fd, *vec, *len);
980 #if !defined (SERVER_MODE) 994 css_set_io_vector (
struct iovec *vec1_p,
struct iovec *vec2_p,
const char *buff,
int len,
int *templen)
996 *templen =
htonl (len);
997 vec1_p->iov_base = (caddr_t) templen;
998 vec1_p->iov_len =
sizeof (int);
999 vec2_p->iov_base = (caddr_t) buff;
1000 vec2_p->iov_len = len;
1032 while (total_len > 0)
1071 struct iovec iov[2];
1075 total_len = len +
sizeof (int);
1095 int templen1, templen2;
1096 struct iovec iov[4];
1102 total_len = len1 + len2 +
sizeof (int) * 2;
1133 int templen1, templen2, templen3;
1134 struct iovec iov[6];
1141 total_len = len1 + len2 + len3 +
sizeof (int) * 3;
1165 int len3,
const char *buff4,
int len4)
1167 int templen1, templen2, templen3, templen4;
1168 struct iovec iov[8];
1176 total_len = len1 + len2 + len3 + len4 +
sizeof (int) * 4;
1182 #if defined(CS_MODE) || defined(SA_MODE) 1192 int len3,
const char *buff4,
int len4,
const char *buff5,
int len5)
1194 int templen1, templen2, templen3, templen4, templen5;
1195 struct iovec iov[10];
1204 total_len = len1 + len2 + len3 + len4 + len5 +
sizeof (int) * 5;
1233 int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
const char *buff6,
int len6)
1235 int templen1, templen2, templen3, templen4, templen5, templen6;
1236 struct iovec iov[12];
1246 total_len = len1 + len2 + len3 + len4 + len5 + len6 +
sizeof (int) * 6;
1252 #if defined(CS_MODE) || defined(SA_MODE) 1262 int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
const char *buff6,
int len6,
1263 const char *buff7,
int len7)
1265 int templen1, templen2, templen3, templen4, templen5, templen6, templen7;
1266 struct iovec iov[14];
1277 total_len = len1 + len2 + len3 + len4 + len5 + len6 + len7 +
sizeof (int) * 7;
1310 int len3,
const char *buff4,
int len4,
const char *buff5,
int len5,
const char *buff6,
int len6,
1311 const char *buff7,
int len7,
const char *buff8,
int len8)
1313 int templen1, templen2, templen3, templen4, templen5, templen6, templen7, templen8;
1314 struct iovec iov[16];
1326 total_len = len1 + len2 + len3 + len4 + len5 + len6 + len7 + len8 +
sizeof (int) * 8;
1332 #if defined(ENABLE_UNUSED_FUNCTION) 1349 int rc,
i, buffer_size;
1351 iov = (
struct iovec *) malloc (
sizeof (
struct iovec) * (num_array * 4));
1356 templen = (
int *) malloc (
sizeof (
int) * (num_array * 2));
1357 if (templen ==
NULL)
1365 for (i = 0; i < num_array; i++)
1369 total_len +=
sizeof (
NET_HEADER) +
sizeof (
int);
1371 buffer_size =
ntohl (header_array[i].buffer_size);
1372 css_set_io_vector (&(iov[i * 4 + 2]), &(iov[i * 4 + 3]), data_array[i], buffer_size, &templen[i * 2 + 1]);
1373 total_len += buffer_size +
sizeof (int);
1397 css_net_send_large_data_with_arg (
CSS_CONN_ENTRY * conn,
const char *header_buffer,
int header_len,
1398 NET_HEADER * header_array,
const char **data_array,
int num_array)
1403 int rc,
i, buffer_size;
1405 iov = (
struct iovec *) malloc (
sizeof (
struct iovec) * (num_array * 4 + 2));
1410 templen = (
int *) malloc (
sizeof (
int) * (num_array * 2 + 1));
1411 if (templen ==
NULL)
1419 css_set_io_vector (&(iov[0]), &(iov[1]), header_buffer, header_len, &templen[0]);
1420 total_len += header_len +
sizeof (int);
1422 for (i = 0; i < num_array; i++)
1425 &templen[i * 2 + 1]);
1427 buffer_size =
ntohl (header_array[i].buffer_size);
1428 css_set_io_vector (&(iov[i * 4 + 4]), &(iov[i * 4 + 5]), data_array[i], buffer_size, &templen[i * 2 + 2]);
1430 total_len += (
sizeof (
NET_HEADER) + buffer_size +
sizeof (
int) * 2);
1455 struct iovec iov[1];
1457 iov[0].iov_base = (caddr_t) buff;
1458 iov[0].iov_len = len;
1479 int transaction_id,
int invalidate_snapshot,
int db_error)
1481 unsigned short flags = 0;
1489 if (invalidate_snapshot)
1511 const char *arg_buffer,
int arg_size,
char *reply_buffer,
int reply_size)
1525 if (reply_buffer && (reply_size > 0))
1530 if (arg_size > 0 && arg_buffer !=
NULL)
1550 #if defined(CS_MODE) || defined(SA_MODE) 1562 css_send_request_no_reply (
CSS_CONN_ENTRY * conn,
int request,
unsigned short *request_id,
char *arg_buffer,
1581 arg_buffer, arg_size));
1600 css_send_req_with_2_buffers (
CSS_CONN_ENTRY * conn,
int request,
unsigned short *request_id,
char *arg_buffer,
1601 int arg_size,
char *data_buffer,
int data_size,
char *reply_buffer,
int reply_size)
1607 if (data_buffer ==
NULL || data_size <= 0)
1621 if (reply_buffer && reply_size > 0)
1633 arg_buffer, arg_size, (
char *) &data_header,
sizeof (
NET_HEADER), data_buffer, data_size));
1654 css_send_req_with_3_buffers (
CSS_CONN_ENTRY * conn,
int request,
unsigned short *request_id,
char *arg_buffer,
1655 int arg_size,
char *data1_buffer,
int data1_size,
char *data2_buffer,
int data2_size,
1656 char *reply_buffer,
int reply_size)
1663 if (data2_buffer ==
NULL || data2_size <= 0)
1665 return (css_send_req_with_2_buffers (conn, request, request_id, arg_buffer, arg_size, data1_buffer, data1_size,
1666 reply_buffer, reply_size));
1678 if (reply_buffer && reply_size > 0)
1693 arg_buffer, arg_size, (
char *) &data1_header,
sizeof (
NET_HEADER), data1_buffer, data1_size,
1694 (
char *) &data2_header,
sizeof (
NET_HEADER), data2_buffer, data2_size));
1714 css_send_req_with_large_buffer (
CSS_CONN_ENTRY * conn,
int request,
unsigned short *request_id,
char *arg_buffer,
1715 int arg_size,
char *data_buffer, INT64 data_size,
char *reply_buffer,
int reply_size)
1719 char **buffer_array;
1720 int num_array, send_data_size;
1723 if (data_buffer ==
NULL || data_size <= 0)
1737 if (reply_buffer && reply_size > 0)
1742 num_array = (int) (data_size / INT_MAX) + 2;
1744 if (headers ==
NULL)
1748 memset (headers, 0,
sizeof (
NET_HEADER) * num_array);
1750 buffer_array = (
char **) malloc (
sizeof (
char *) * num_array);
1751 if (buffer_array ==
NULL)
1759 buffer_array[0] = arg_buffer;
1761 for (i = 1; i < num_array; i++)
1763 if (data_size > INT_MAX)
1765 send_data_size = INT_MAX;
1769 send_data_size = (int) data_size;
1774 buffer_array[
i] = data_buffer;
1776 data_buffer += send_data_size;
1777 data_size -= send_data_size;
1780 rc = css_net_send_large_data_with_arg (conn, (
char *) &local_header,
sizeof (
NET_HEADER), headers,
1781 (
const char **) buffer_array, num_array);
1804 int arg_buffer_size)
1811 int arg_buffer_size)
1824 if (arg_buffer_size > 0 && arg_buffer !=
NULL)
1829 sizeof (
NET_HEADER), arg_buffer, arg_buffer_size));
1855 #if defined(SERVER_MODE) 1870 #if defined(SERVER_MODE) 1882 css_send_two_data (
CSS_CONN_ENTRY * conn,
unsigned short rid,
const char *buffer1,
int buffer1_size,
1883 const char *buffer2,
int buffer2_size)
1899 return (
css_net_send4 (conn, (
char *) &header1,
sizeof (
NET_HEADER), buffer1, buffer1_size, (
char *) &header2,
1900 sizeof (
NET_HEADER), buffer2, buffer2_size));
1916 css_send_three_data (
CSS_CONN_ENTRY * conn,
unsigned short rid,
const char *buffer1,
int buffer1_size,
1917 const char *buffer2,
int buffer2_size,
const char *buffer3,
int buffer3_size)
1937 return (
css_net_send6 (conn, (
char *) &header1,
sizeof (
NET_HEADER), buffer1, buffer1_size, (
char *) &header2,
1958 css_send_four_data (
CSS_CONN_ENTRY * conn,
unsigned short rid,
const char *buffer1,
int buffer1_size,
1959 const char *buffer2,
int buffer2_size,
const char *buffer3,
int buffer3_size,
const char *buffer4,
1984 return (
css_net_send8 (conn, (
char *) &header1,
sizeof (
NET_HEADER), buffer1, buffer1_size, (
char *) &header2,
1986 buffer3_size, (
char *) &header4,
sizeof (
NET_HEADER), buffer4, buffer4_size));
1989 #if defined(ENABLE_UNUSED_FUNCTION) 2001 css_send_large_data (
CSS_CONN_ENTRY * conn,
unsigned short rid,
const char **buffers,
int *buffers_size,
2013 if (headers ==
NULL)
2018 for (i = 0; i < num_buffers; i++)
2024 rc = css_net_send_large_data (conn, headers, buffers, num_buffers);
2045 #if defined (SERVER_MODE) 2060 #if defined (ENABLE_UNUSED_FUNCTION) 2070 css_local_host_name (
CSS_CONN_ENTRY * conn,
char *hostname,
size_t namelen)
2094 css_peer_host_name (
CSS_CONN_ENTRY * conn,
char *hostname,
size_t namelen)
2110 #if !defined (SERVER_MODE) 2210 #if !defined (SERVER_MODE) 2218 #if defined(SERVER_MODE) 2224 assert (ip_info && address);
2226 for (i = 0; i < ip_info->
num_list; i++)
2234 else if (memcmp ((
void *) &ip_info->
address_list[address_index + 1], (
void *) address,
2263 int ip_address_list_buffer_size;
2265 bool is_current_db_section;
2267 if (out_ip_info ==
NULL)
2272 fd_ip_list = fopen (filename,
"r");
2274 if (fd_ip_list ==
NULL)
2280 is_current_db_section =
false;
2283 if (ip_info ==
NULL)
2286 fclose (fd_ip_list);
2292 ip_info->
address_list = (
unsigned char *) malloc (ip_address_list_buffer_size);
2302 while (fgets (buf, 32, fd_ip_list))
2304 char *token, *
p, *save =
NULL;
2307 p = strchr (buf,
'#');
2319 if (is_current_db_section ==
false && strncmp (buf,
"[@", 2) == 0 && buf[
strlen (buf) - 1] ==
']')
2321 buf[
strlen (buf) - 1] =
'\0';
2322 if (strcasecmp (dbname, buf + 2) == 0)
2324 is_current_db_section =
true;
2329 if (is_current_db_section ==
false)
2334 if (strncmp (buf,
"[@", 2) == 0 && buf[
strlen (buf) - 1] ==
']')
2336 buf[
strlen (buf) - 1] =
'\0';
2337 if (strcasecmp (dbname, buf + 2) != 0)
2343 token = strtok_r (buf,
".", &save);
2347 if (address_index >= ip_address_list_buffer_size)
2349 ip_address_list_buffer_size *= 2;
2354 (
size_t) ip_address_list_buffer_size);
2359 for (i = 0; i < 4; i++)
2367 if (strcmp (token,
"*") == 0)
2373 int adr = 0, result;
2377 if (result != 0 || adr > 255 || adr < 0)
2383 ip_info->
address_list[address_index + 1 +
i] = (
unsigned char) adr;
2386 token = strtok_r (
NULL,
".", &save);
2388 if (i == 3 && token !=
NULL)
2398 fclose (fd_ip_list);
2400 *out_ip_info = ip_info;
2405 fclose (fd_ip_list);
2413 css_trim_str (
char *str)
2422 for (s = str; *s !=
'\0' && (*s ==
' ' || *s ==
'\t' || *s ==
'\n' || *s ==
'\r'); s++)
2434 for (p = s; *p !=
'\0'; p++)
2438 for (p--; *p ==
' ' || *p ==
'\t' || *p ==
'\n' || *p ==
'\r'; p--)
2446 memmove (str, s,
strlen (s) + 1);
2470 memset ((
char *) &header, 0,
sizeof (
NET_HEADER));
2497 nbytes =
css_readn (fd, (
char *) &size,
sizeof (
int), timeout);
2498 if (nbytes !=
sizeof (
int))
2502 size =
ntohl (size);
2508 p = (
char *) &header;
2509 nbytes =
css_readn (fd, p, size, timeout);
2526 #if !defined (CS_MODE) 2542 const int num_cols = 4;
2543 const int default_num_tuple = 10;
2547 #if defined(SERVER_MODE) 2563 #if defined(SERVER_MODE) 2567 if (access_status_array ==
NULL)
2586 #if defined(SERVER_MODE) 2590 if (access_status ==
NULL)
2613 if (access_status_array !=
NULL)
2628 if (access_status_array !=
NULL)
2651 int i, attr_idx = -1;
2652 bool attr_info_inited;
2653 bool scan_cache_inited;
2654 char *rec_attr_name_p =
NULL, *
string =
NULL;
2655 const char *user_name =
NULL;
2660 HEAP_ATTRVALUE *heap_value;
2675 attr_info_inited =
true;
2678 scan_cache_inited =
true;
2687 for (i = 0; i < attr_info.num_values; i++)
2689 int alloced_string = 0;
2690 bool set_break =
false;
2699 rec_attr_name_p = string;
2701 if (rec_attr_name_p ==
NULL)
2706 if (strcmp (
"name", rec_attr_name_p) == 0)
2714 if (
string !=
NULL && alloced_string == 1)
2719 if (set_break ==
true)
2725 scan_cache_inited =
false;
2740 if (mvcc_snapshot ==
NULL)
2751 scan_cache_inited =
true;
2755 scan =
heap_next (thread_p, &hfid,
NULL, &inst_oid, &recdes, &scan_cache,
PEEK);
2764 for (i = 0, heap_value = attr_info.values; i < attr_info.num_values; i++, heap_value++)
2766 if (heap_value->attrid == attr_idx)
2772 else if (scan ==
S_END)
2792 if (access_status !=
NULL)
2809 if (scan_cache_inited ==
true)
2814 if (attr_info_inited ==
true)
2838 if (access_status_array ==
NULL)
2843 for (i = 0; i < num_user; i++)
2845 if (access_status_array[i] !=
NULL && strcmp (access_status_array[i]->db_user, user_name) == 0)
2847 access_status = access_status_array[
i];
2849 access_status_array[
i] =
NULL;
2854 return access_status;
2870 if (access_status_array ==
NULL)
2875 for (i = 0; i < num_user; i++)
2877 if (access_status_array[i] !=
NULL)
2879 access_status = access_status_array[
i];
2881 access_status_array[
i] =
NULL;
2886 return access_status;
2895 #if defined (WINDOWS) 2896 rc = WSAPoll (fds, num_of_fds, timeout);
2898 rc = poll (fds, num_of_fds, timeout);
2906 css_conn_entry::set_tran_index (
int tran_index)
2918 css_conn_entry::get_tran_index ()
2925 css_conn_entry::add_pending_request ()
2927 ++pending_request_count;
2931 css_conn_entry::start_request ()
2933 --pending_request_count;
2937 css_conn_entry::has_pending_request ()
const 2939 return pending_request_count != 0;
2943 css_conn_entry::init_pending_request ()
2945 pending_request_count = 0;
static int css_net_send3(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3)
unsigned char address_list[ACL_MAX_IP_COUNT *IP_BYTE_COUNT]
int db_make_datetime(DB_VALUE *value, const DB_DATETIME *datetime)
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
static void css_set_networking_error(SOCKET fd)
#define HA_SERVER_STATE_IDLE_STR
void showstmt_free_array_context(THREAD_ENTRY *thread_p, SHOWSTMT_ARRAY_CONTEXT *ctx)
#define ER_CSS_RECV_OR_SEND
void css_shutdown_conn(CSS_CONN_ENTRY *conn)
#define HA_LOG_APPLIER_STATE_UNREGISTERED_STR
unsigned int htonl(unsigned int from)
int parse_int(int *ret_p, const char *str_p, int base)
const int LOG_SYSTEM_TRAN_INDEX
const char * boot_db_name(void)
int css_net_send3_with_socket(SOCKET &socket, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3)
#define NET_HEADER_FLAG_INVALIDATE_SNAPSHOT
char db_user[DB_MAX_USER_LENGTH]
void css_set_io_vector(struct iovec *vec1_p, struct iovec *vec2_p, const char *buff, int len, int *templen)
int heap_scancache_quick_start_root_hfid(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
static bool css_default_check_server_alive_fn(const char *db_name, const char *db_host)
#define OID_SET_NULL(oidp)
int css_net_send_buffer_only(CSS_CONN_ENTRY *conn, const char *buff, int len, int timeout)
void css_register_check_server_alive_fn(CSS_CHECK_SERVER_ALIVE_FN callback_fn)
int css_read_ip_info(IP_INFO **out_ip_info, char *filename)
SHOWSTMT_ARRAY_CONTEXT * showstmt_alloc_array_context(THREAD_ENTRY *thread_p, int num_total, int num_cols)
static LAST_ACCESS_STATUS * css_get_unused_access_status(LAST_ACCESS_STATUS **access_status_array, int num_user)
#define er_log_debug(...)
static int css_net_send4(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4)
char * getuserid(char *string, int size)
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
void css_read_remaining_bytes(SOCKET fd, int len)
int css_platform_independent_poll(POLL_FD *fds, int num_of_fds, int timeout)
#define ER_OPEN_ACCESS_LIST_FILE
#define HA_LOG_APPLIER_STATE_WORKING_STR
char host[CUB_MAXHOSTNAMELEN]
int heap_scancache_start(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache, const HFID *hfid, const OID *class_oid, int cache_last_fix_page, int is_indexscan, MVCC_SNAPSHOT *mvcc_snapshot)
int css_net_send(CSS_CONN_ENTRY *conn, const char *buff, int len, int timeout)
unsigned short css_get_request_id(CSS_CONN_ENTRY *conn)
int heap_attrinfo_start(THREAD_ENTRY *thread_p, const OID *class_oid, int requested_num_attrs, const ATTR_ID *attrids, HEAP_CACHE_ATTRINFO *attr_info)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int css_send_request(CSS_CONN_ENTRY *conn, int command, unsigned short *request_id, const char *arg_buffer, int arg_buffer_size)
CSS_CHECK_SERVER_ALIVE_FN css_check_server_alive_fn
void css_get_user_access_status(int num_user, LAST_ACCESS_STATUS **access_status_array)
static int css_make_access_status_exist_user(THREAD_ENTRY *thread_p, OID *class_oid, LAST_ACCESS_STATUS **access_status_array, int num_user, SHOWSTMT_ARRAY_CONTEXT *ctx)
int prm_get_integer_value(PARAM_ID prm_id)
#define HA_MODE_REPLICA_STR
#define ER_OUT_OF_VIRTUAL_MEMORY
#define HA_SERVER_STATE_DEAD_STR
char css_Net_magic[CSS_NET_MAGIC_SIZE]
const char * css_ha_server_state_string(HA_SERVER_STATE state)
#define HA_SERVER_STATE_MAINTENANCE_STR
#define IS_INVALID_SOCKET(socket)
#define DEFAULT_HEADER_DATA
static int css_sprintf_conn_infoids(SOCKET fd, const char **client_user_name, const char **client_host_name, int *client_pid)
void db_localdatetime(time_t *epoch_time, DB_DATETIME *datetime)
#define HA_SERVER_STATE_TO_BE_STANDBY_STR
static enum scanner_mode mode
#define ER_INACCESSIBLE_IP
enum ha_log_applier_state HA_LOG_APPLIER_STATE
#define HA_LOG_APPLIER_STATE_ERROR_STR
void css_shutdown_socket(SOCKET fd)
int heap_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, const OID *inst_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, HEAP_CACHE_ATTRINFO *attr_info)
#define CSS_TRUNCATE_BUFFER_SIZE
unsigned short htons(unsigned short from)
bool css_peer_alive(SOCKET sd, int timeout)
#define db_private_free_and_init(thrd, ptr)
#define CHECK_SERVER_IS_ALIVE()
struct packet_header NET_HEADER
DB_VALUE * showstmt_alloc_tuple_in_context(THREAD_ENTRY *thread_p, SHOWSTMT_ARRAY_CONTEXT *ctx)
static int css_net_send2(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2)
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
const char * css_ha_mode_string(HA_MODE mode)
static void error(const char *msg)
static void css_default_server_timeout_fn(void)
#define HA_SERVER_STATE_STANDBY_STR
int css_readn(SOCKET fd, char *ptr, int nbytes, int timeout)
bool(* CSS_CHECK_SERVER_ALIVE_FN)(const char *, const char *)
#define HFID_IS_NULL(hfid)
int css_send_io_vector_with_socket(SOCKET &socket, struct iovec *vec_p, ssize_t total_len, int vector_length, int timeout)
static int css_send_io_vector(CSS_CONN_ENTRY *conn, struct iovec *vec_p, ssize_t total_len, int vector_length, int timeout)
OID * db_get_oid(const DB_VALUE *value)
static LAST_ACCESS_STATUS * css_get_access_status_with_name(LAST_ACCESS_STATUS **access_status_array, int num_user, const char *user_name)
int css_check_ip(IP_INFO *ip_info, unsigned char *address)
void(* CSS_SERVER_TIMEOUT_FN)(void)
int css_free_ip_info(IP_INFO *ip_info)
#define free_and_init(ptr)
static CSS_SERVER_TIMEOUT_FN css_server_timeout_fn
int or_get_attrname(RECDES *record, int attrid, char **string, int *alloced_string)
int css_send_request_with_socket(SOCKET &socket, int command, unsigned short *request_id, const char *arg_buffer, int arg_buffer_size)
#define HA_SERVER_STATE_TO_BE_ACTIVE_STR
static int css_net_send8(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6, const char *buff7, int len7, const char *buff8, int len8)
int css_queue_user_data_buffer(CSS_CONN_ENTRY *conn, unsigned short request_id, int size, char *buffer)
int db_make_string_copy(DB_VALUE *value, DB_CONST_C_CHAR str)
void css_register_server_timeout_fn(CSS_SERVER_TIMEOUT_FN callback_fn)
int css_check_magic_with_socket(SOCKET fd)
#define pthread_mutex_lock(b)
int logtb_find_client_name_host_pid(int tran_index, const char **client_prog_name, const char **client_user_name, const char **client_host_name, int *client_pid)
static int css_net_send6(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6)
int css_net_recv(SOCKET fd, char *buffer, int *maxlen, int timeout)
int css_send_request_with_data_buffer(CSS_CONN_ENTRY *conn, int request, unsigned short *request_id, const char *arg_buffer, int arg_size, char *reply_buffer, int reply_size)
int db_make_null(DB_VALUE *value)
void css_set_net_header(NET_HEADER *header_p, int type, short function_code, int request_id, int buffer_size, int transaction_id, int invalidate_snapshot, int db_error)
int css_get_peer_name(SOCKET sockfd, char *hostname, size_t len)
int css_get_sock_name(SOCKET sockfd, char *hostname, size_t len)
CSS_CONN_ENTRY * css_find_conn_from_fd(SOCKET fd)
static const int CSS_TCP_MIN_NUM_RETRIES
int css_send_magic(CSS_CONN_ENTRY *conn)
int css_user_access_status_start_scan(THREAD_ENTRY *thread_p, int type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
int css_vector_send(SOCKET fd, struct iovec *vec[], int *len, int bytes_written, int timeout)
#define pthread_mutex_unlock(a)
int css_net_read_header(SOCKET fd, char *buffer, int *maxlen, int timeout)
unsigned int ntohl(unsigned int from)
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
int css_send_data(CSS_CONN_ENTRY *conn, unsigned short rid, const char *buffer, int buffer_size)
enum ha_server_state HA_SERVER_STATE
SCAN_CODE heap_next(THREAD_ENTRY *thread_p, const HFID *hfid, OID *class_oid, OID *next_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking)
int css_check_magic(CSS_CONN_ENTRY *conn)
int css_send_error(CSS_CONN_ENTRY *conn, unsigned short rid, const char *buffer, int buffer_size)
#define HA_SERVER_STATE_ACTIVE_STR
#define CUB_MAXHOSTNAMELEN
int heap_get_class_info(THREAD_ENTRY *thread_p, const OID *class_oid, HFID *hfid_out, FILE_TYPE *ftype_out, char **classname_out)
int css_net_send_with_socket(SOCKET &socket, const char *buff, int len, int timeout)
#define GETHOSTNAME(p, l)
static int css_net_send7(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5, const char *buff6, int len6, const char *buff7, int len7)
DB_CONST_C_CHAR db_get_string(const DB_VALUE *value)
#define ER_INVALID_ACCESS_IP_CONTROL_FILE_FORMAT
#define HA_LOG_APPLIER_STATE_DONE_STR
static int css_net_send5(CSS_CONN_ENTRY *conn, const char *buff1, int len1, const char *buff2, int len2, const char *buff3, int len3, const char *buff4, int len4, const char *buff5, int len5)
const char * css_ha_applier_state_string(HA_LOG_APPLIER_STATE state)
int css_send_magic_with_socket(SOCKET &socket)
#define HA_LOG_APPLIER_STATE_RECOVERING_STR
SCAN_CODE heap_get_class_record(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes_p, HEAP_SCANCACHE *scan_cache, int ispeeking)