26 #include <sys/types.h>
30 #include <netinet/in.h>
41 #include <freetds/utils/dlist.h>
46 #define MAX_POOL_USERS 1024
66 TDS_POOL_EXECUTE execute;
79 DLIST_FIELDS(dlist_user_item);
81 TDS_USER_STATE user_state;
88 DLIST_FIELDS(dlist_member_item);
94 #define DLIST_PREFIX dlist_member
95 #define DLIST_LIST_TYPE dlist_members
96 #define DLIST_ITEM_TYPE TDS_POOL_MEMBER
97 #include <freetds/utils/dlist.tmpl.h>
99 #define DLIST_PREFIX dlist_user
100 #define DLIST_LIST_TYPE dlist_users
101 #define DLIST_ITEM_TYPE TDS_POOL_USER
102 #include <freetds/utils/dlist.tmpl.h>
112 char *server_password;
117 tds_mutex events_mtx;
118 TDS_SYS_SOCKET listen_fd;
119 TDS_SYS_SOCKET wakeup_fd;
120 TDS_SYS_SOCKET event_fd;
123 int num_active_members;
124 dlist_members active_members;
125 dlist_members idle_members;
133 unsigned long user_logins;
134 unsigned long member_logins;
140 void pool_process_members(
TDS_POOL * pool, fd_set * rfds, fd_set * wfds);
142 void pool_mbr_init(
TDS_POOL * pool);
143 void pool_mbr_destroy(
TDS_POOL * pool);
151 void pool_process_users(
TDS_POOL * pool, fd_set * rfds, fd_set * wfds);
152 void pool_user_init(
TDS_POOL * pool);
153 void pool_user_destroy(
TDS_POOL * pool);
163 int pool_write(TDS_SYS_SOCKET sock,
const void *buf,
size_t len);
167 bool pool_read_conf_files(
const char *path,
const char *poolname,
TDS_POOL * pool,
char **err);
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:531
DSTR user_name
account for login
Definition: tds.h:529
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:541
TDSLOGIN * tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
tds_read_config_info() will fill the tds connection structure based on configuration information gath...
Definition: config.c:138
bool tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param)
Read a section of configuration file (INI style file)
Definition: config.c:504
DSTR server_charset
charset of server e.g.
Definition: tds.h:518
char * tds_get_home_file(const char *file)
Return filename from HOME directory.
Definition: config.c:326
void tds_fix_login(TDSLOGIN *login)
Fix configuration after reading it.
Definition: config.c:286
Definition: winsetup.c:62
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:354
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:524
DSTR dsn
edited name of the data source
Definition: winsetup.c:65
DSTR crlfile
certificate revocation file
Definition: tds.h:526
bool tds_set_server(TDSLOGIN *tds_login, const char *server) TDS_WUR
Set the servername in a TDSLOGIN structure.
Definition: login.c:125
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type.
Definition: query.c:345
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:107
static void tds_dstr_init(DSTR *s)
init a string with empty
Definition: string.h:53
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:551
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:285
TDSRET tds_process_simple_query(TDSSOCKET *tds)
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results,...
Definition: token.c:876
volatile unsigned char in_cancel
indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cance...
Definition: tds.h:1206
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:794
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
unsigned in_len
input buffer length
Definition: tds.h:1170
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
DSTR cafile
certificate authorities file
Definition: tds.h:525
TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN *login)
Set TDS version from given string.
Definition: config.c:905
Structure to hold a string.
Definition: string.h:36
TDSRET tds_set_interfaces_file_loc(const char *interf)
Set the full name of interface file.
Definition: config.c:948
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:523
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:800
DSTR origdsn
original name of the data source
Definition: winsetup.c:64
TDSLOGIN * login
everything else
Definition: winsetup.c:66
TDSENV env
environment is shared between all sessions
Definition: tds.h:1080
#define tds_dstr_empty(s)
Make a string empty.
Definition: string.h:91
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:513
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:78
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:515
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition: tdsstring.c:134
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:193
static int search_interface_file(TDSLOGIN *login, const char *dir, const char *file, const char *host)
Open and read the file 'file' searching for a logical server by the name of 'host'.
Definition: config.c:1051
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
static int tds_lookup_port(const char *portname)
Given a portname lookup the port.
Definition: config.c:1013
#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition: string.h:49
static int parse_server_name_for_port(TDSLOGIN *connection, TDSLOGIN *login, bool update_server)
Check the server name to find port info first Warning: connection-> & login-> are all modified when n...
Definition: config.c:1280
dlist_users waiters
users in wait state
Definition: pool.h:128
unsigned in_pos
current position in in_buf
Definition: tds.h:1168
Provide poll call where missing.
bool tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
Definition: config.c:347
unsigned char * in_buf
Input buffer.
Definition: tds.h:1154
int port
port of database service
Definition: tds.h:514
static int tds_read_interfaces(const char *server, TDSLOGIN *login)
Try to find the IP number and port for a (possibly) logical server name.
Definition: config.c:1174
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
unsigned char out_flag
output buffer type
Definition: tds.h:1172
@ TDS_WRITING
client is writing data
Definition: tds.h:792
int tdserror(const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
Call the client library's error handler (for library-generated errors only)
Definition: util.c:307
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
DSTR password
password of account login
Definition: tds.h:530
Information for a server connection.
Definition: tds.h:1141
const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void)
Return a structure capturing the compile-time settings provided to the configure script.
Definition: config.c:1324
int tds_put_string(TDSSOCKET *tds, const char *s, int len)
Output a string to wire automatic translate string to unicode if needed.
Definition: write.c:93
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:112
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:522
struct addrinfo * tds_lookup_host(const char *servername)
Get the IP address for a hostname.
Definition: config.c:974
A structure to hold all the compile-time settings.
Definition: tds.h:82
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2550
void tdsdump_dump_buf(const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
Dump the contents of data into the log file in a human readable format.
Definition: log.c:256
DSTR * tds_dstr_copyn(DSTR *s, const char *src, size_t length)
Set string to a given buffer of characters.
Definition: tdsstring.c:77
char * database
database name
Definition: tds.h:971