-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add io wait callback for blockin io operations. #23
Add io wait callback for blockin io operations. #23
Conversation
Add a io wait callback that will be called instead of base io witing handlers.
@@ -208,6 +208,7 @@ extern const char *SQLSTATE_UNKNOWN; | |||
/* MariaDB specific */ | |||
MYSQL_PROGRESS_CALLBACK=5999, | |||
MYSQL_OPT_NONBLOCK, | |||
MYSQL_OPT_IO_WAIT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New options (which are not supported by MySQL server should be prefixed with MariaDB and should be added to the end of enumeration.
@@ -316,6 +317,7 @@ struct st_mysql_options { | |||
int (*local_infile_error)(void *, char *, unsigned int); | |||
void *local_infile_userdata; | |||
struct st_mysql_options_extension *extension; | |||
int (*io_wait)(my_socket handle, my_bool is_read, int timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be added to mysql->options.extension to avoid ABI breakage.
@@ -2716,6 +2716,9 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) | |||
} | |||
mysql->options.extension->async_context= ctxt; | |||
break; | |||
case MYSQL_OPT_IO_WAIT: | |||
mysql->options.io_wait = (int(*)(my_socket, bool, int))arg1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback should be registered in mysql->options.extension->io_wait
Replaced by PR #71 |
Add a io wait callback that will be called instead of base io witing
handlers.
We use mariadb-connector-c for our mariadb/mysql connector https://github.com/tarantool/mysql for tarantool nosql database https://github.com/tarantool/tarantool.
Mariadb connector uses own internal fiber implementation for async operations and need to special wrap for async api function (_start/_cont), but tarantool already has it own fibers.
I added one option for mysql connection that allowed callback from pvio objects for io polling, in this case standart api calls can be used asynchronously without wrapping, because we will need to call some more methods that already exist in future (ex. for replication from mariadb databases).
Little example can be found at our git repo https://github.com/tarantool/mysql/blob/master/mysql/driver.c