Skip to content

Commit

Permalink
Give the possibility of the client to pass a factory
Browse files Browse the repository at this point in the history
  • Loading branch information
faizshukri committed Nov 24, 2015
1 parent 7e7c2c0 commit 85e4fcf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ext/mysqlnd/mysqlnd_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(MYSQLND_CLASS_METHODS_TYP

mysqlnd_stats_init(&data->stats, STAT_LAST, persistent);

data->protocol_frame_codec = mysqlnd_pfc_init(persistent, data->stats, data->error_info);
data->vio = mysqlnd_vio_init(persistent, data->stats, data->error_info);
data->protocol_frame_codec = mysqlnd_pfc_init(persistent, factory, data->stats, data->error_info);
data->vio = mysqlnd_vio_init(persistent, factory, data->stats, data->error_info);
data->payload_decoder_factory = mysqlnd_protocol_payload_decoder_factory_init(data, persistent);
data->command_factory = mysqlnd_command_factory_get();

Expand Down
5 changes: 3 additions & 2 deletions ext/mysqlnd/mysqlnd_protocol_frame_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,12 @@ MYSQLND_CLASS_METHODS_END;

/* {{{ mysqlnd_pfc_init */
PHPAPI MYSQLND_PFC *
mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
{
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *factory = object_factory? object_factory : &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory);
MYSQLND_PFC * pfc;
DBG_ENTER("mysqlnd_pfc_init");
pfc = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_protocol_frame_codec(persistent, stats, error_info);
pfc = factory->get_protocol_frame_codec(persistent, stats, error_info);
DBG_RETURN(pfc);
}
/* }}} */
Expand Down
4 changes: 2 additions & 2 deletions ext/mysqlnd/mysqlnd_protocol_frame_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#ifndef MYSQLND_PROTOCOL_FRAME_CODEC_H
#define MYSQLND_PROTOCOL_FRAME_CODEC_H

PHPAPI MYSQLND_PFC * mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
PHPAPI MYSQLND_PFC * mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC * const pfc, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);

#endif /* MYSQLND_PROTOCOL_FRAME_CODEC_H */

Expand Down
5 changes: 3 additions & 2 deletions ext/mysqlnd/mysqlnd_vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,12 @@ MYSQLND_CLASS_METHODS_END;

/* {{{ mysqlnd_vio_init */
PHPAPI MYSQLND_VIO *
mysqlnd_vio_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
mysqlnd_vio_init(zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info)
{
MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *factory = object_factory? object_factory : &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory);
MYSQLND_VIO * vio;
DBG_ENTER("mysqlnd_vio_init");
vio = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_vio(persistent, stats, error_info);
vio = factory->get_vio(persistent, stats, error_info);
DBG_RETURN(vio);
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqlnd/mysqlnd_vio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef MYSQLND_VIO_H
#define MYSQLND_VIO_H

PHPAPI MYSQLND_VIO * mysqlnd_vio_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
PHPAPI MYSQLND_VIO * mysqlnd_vio_init(zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
PHPAPI void mysqlnd_vio_free(MYSQLND_VIO * const vio, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);

#endif /* MYSQLND_VIO_H */
Expand Down

0 comments on commit 85e4fcf

Please sign in to comment.