Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Add io wait callback for blockin io operations. #23

wants to merge 1 commit into from

Conversation

GeorgyKirichenko
Copy link
Contributor

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

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,
Copy link
Collaborator

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);
Copy link
Collaborator

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;
Copy link
Collaborator

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

@9EOR9
Copy link
Collaborator

9EOR9 commented Mar 4, 2022

Replaced by PR #71

@9EOR9 9EOR9 closed this Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants