/* {{{ size_t ma_pvio_write */ ssize_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length) { ssize_t r= 0; if (!pvio) return -1; /* secure connection */ #ifdef HAVE_TLS if (pvio->ctls) { r= ma_pvio_tls_write(pvio->ctls, buffer, length); goto end; } else #endif if (IS_PVIO_ASYNC_ACTIVE(pvio)) { r= ma_pvio_write_async(pvio, buffer, length); goto end; } else { if (IS_PVIO_ASYNC(pvio)) { /* If switching from non-blocking to blocking API usage, set the socket back to blocking mode. */ my_bool old_mode; ma_pvio_blocking(pvio, TRUE, &old_mode); } } if (pvio->methods->write) r= pvio->methods->write(pvio, buffer, length); end: if (pvio_callback) { void (*callback)(int mode, MYSQL *mysql, const uchar *buffer, size_t length); LIST *p= pvio_callback; while (p) { callback= p->data; callback(1, pvio->mysql, buffer, r); p= p->next; } } return r; }
/* {{{ size_t ma_pvio_write */ size_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length) { size_t r; if (!pvio) return -1; /* secure connection */ #ifdef HAVE_SSL if (pvio->ctls) { r= ma_pvio_tls_write(pvio->ctls, buffer, length); goto end; } else #endif #ifdef HAVE_NONBLOCK if (IS_PVIO_ASYNC_ACTIVE(pvio)) { r= ma_pvio_write_async(pvio, buffer, length); goto end; } else #endif { if (IS_PVIO_ASYNC(pvio)) { /* If switching from non-blocking to blocking API usage, set the socket back to blocking mode. */ my_bool old_mode; ma_pvio_blocking(pvio, TRUE, &old_mode); } } if (pvio->methods->write) r= pvio->methods->write(pvio, buffer, length); end: if (pvio->callback) pvio->callback(pvio, 0, buffer, r); return r; }