Fixed different behavior of pvio_is_alive (which was first used
with fix of CONC-589). Both for sockets and named pipe the function
now returns true if the connection is alive, otherwise false.
See https://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.h.html, or the other files in this project referencing `poll.h`:
```console
% grep -r 'poll.h'
libmariadb/ma_net.c:#include <poll.h>
libmariadb/mariadb_lib.c:#include <poll.h>
plugins/pvio/pvio_socket.c:#include <sys/poll.h>
unittest/libmariadb/async.c:#include <poll.h>
```
When connecting via socket (non unix-socket) the connection can't
be established if the wait function (usleep) returns an error and
modifies errno. This is the case on MacOSX, where usleep() returns
-1 and sets errno to ETIMED_OUT. This patch saves errno from connect()
call and restores it after usleep.
This bug was introduced with PR204 (commit dfe3563192)
When connecting via socket (non unix-socket) the connection can't
be established if the wait function (usleep) returns an error and
modifies errno. This is the case on MacOSX, where usleep() returns
-1 and sets errno to ETIMED_OUT. This patch saves errno from connect()
call and restores it after usleep.
This bug was introduced with PR204 (commit dfe3563192)
A retry interval is added in the loop to avoid exhausting
the CPU resource. Also the elapsed time in the loop will be
checked and break if it passed the timeout threshold.
Kudos to Hugo Wen who reported this issue and provided the fix!
Various coverity scan fixes, including CONC-452 and CONC-453.
Special thanks to Lukas Javorsky for fixing numerous covscan
issues (This patch includes part of his pull request #126).
Coverity scan build was using the following cmake parameters:
-WITH_EXTERNAL_ZLIB=ON -DWITH_UNIT_TESTS=OFF.
CWE-416 (use after free) in dtoa.c (from netlib) is still open.
POWER and other architectures that define char(as my_bool) to be unsigned (as the C
standard leaves this undefined). This resulted in error branches being
unreachabe as indicated by the below compile warnings.
plugins/pvio/pvio_socket.c:763:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:875:46: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:907:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
ma_hext2int: signed char - prevent compiler errors when char is unsigned.
libmariadb/ma_tls.c:169:31: warning: comparison of constant -1 with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
if ((d1 = ma_hex2int(*p)) == - 1 ||
~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
libmariadb/ma_tls.c:170:35: warning: comparison of constant -1 with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
(d2 = ma_hex2int(*(p+1))) == -1 ||
~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
To fix this all the pvio_*_blocking functions have been changed to use
int as a return value.
Other my_bool/char differences fixed:
mariadb_dyncol_val_str: fix prototype to use char - like implemented function.
unittest: bind.is_null is my_bool* so we use a my_bool.
Thanks to Sergey Vojtovich:
On OS X sockaddr_un is defined as:
struct sockaddr_un
{
u_char sun_len;
u_char sun_family;
char sun_path[104];
};
There is a comment in man 7 unix (on linux):
On Linux, the above offsetof() expression equates to the same value as sizeof(sa_family_t), but some other implementations include other fields before sun_path, so the offsetof() expression more portably describes the size of the address structure.
As such use the offsetof for Linux and use the previous sizeof(UNIXaddr)
for non-unix platforms as that's what worked before and they don't
support abstract sockets so there's no compatibility problem..
Based off: 569e3ad1ead6469fa9019a399dcef8d4f2fb71b4 (in server)
Unlike UNIX filesystem sockets, abstract sockets need to be length
limited because nulls are insignificant in the name.
Limiting this doesn't have any effect on UNIX filesystem sockets.
Thanks to Sergey Vojtovich
Plugin configuration happens now in CMakeLists.txt files in corresponding plugin directories.
plugins.cmake now contains REGISTER_PLUGIN_FUNCTION which accepts the following parameters:
- TARGET: the name of the plugin (dynamic plugins will be named ${TARGET}.so (or .dll)
- SOURCES: source files
- LIBRARIES: additional libraries for linking
- INCLUDES: include directories
- CONFIGURATIONS: possible plugin configurations: valid arguments are DYNAMIC, STATIC, OFF
- DEFAULT: default configuration (see CONFIGURATIONS)
- COMPILE_OPTIONS: compiler flags
The default plugin configuration can be specified via cmake parameter -DCLIENT_PLUGIN_${TARGET}=[DYNAMIC|STATIC|OFF]
Consistent with the server implementation extend the
client connection via unix socket to use an abstract
socket where the start of the path is '@'.
When this occurs the remainder of the name is the
abstract socket socket name. This is consistent with the
approached used by systemd in socket activation.
- added travis support
- fixed appveyor settings
- fixed some warnings (gcc 4.8)
- removed sleep commands
- disabled failing tests when running against MySQL server,
mostly related to stored procedures and binary protocol
- reverted fix for MDEV_10361
Still open: TLS/SSL appveyor tests, since .msi installation on appveyor doesn't provide certificates.
- STDCALL is ignored for variable argument functions.
- __attribute__ does work for Clang (also if that pretends to be MSVC)
- remove unused function
- simplify ma_getopt, fixes some strange compile error in clang (about
SSE intrinsics)
- fix some clang warnings
fix for timeout failures in buildbot
fixed sha256 password plugin:
instead of using mysql_ssl_cipher, we rely on client_flag & CLIENT_SSL
to check if a secure connection is used.
- Fix a breaking change where
SP_PROT_TLS1_2_CLIENT bit was set in Cred.grbitEnabledProtocols by default.
This makes any SSL connection to Windows server fai, because
all yassl-based servers, in all MariaDB versions would abort
a client that is trying to use TLS1.2
(This is covered MDEV-12190)
As a consequence, client on Windows would not connect to any
server on Windows. For compatibility reasons therefore, 1.2 should NOT
be used by clients by default, otherwise it will break applications
connectivity to both Oracle MySQL and MariaDB's yassl based servers.
This also holds after MDEV-12190 is fixed, because older servers
will be used for a while.
- Cred.dwFlag was missing SCH_CRED_NO_DEFAULT_CREDS flag,
which resulted in a popup on the build servers, asking to insert
a smartcard during client SSL handshake.
Smaller bugs in schannel :
cipher_name() was returning pointer to member of stack allocated struct
Socket IO fixes
- errno rather than WSAGetLastError() was tested on Windows in
pvio_socket_write/pvio_socket_read.
Fixed by using socker_errno and simplided function to avoid numerious #ifdef _WIN32
- simplified vio_set_blocking, it had a rather inefficient implementation
setting the same flags with ioctlsocket/fcntl over and over again.