Skip to content

PHPC-605: Rely on libmongoc for socket handling and TLS #361

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

Merged
merged 7 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
807 changes: 123 additions & 684 deletions php_phongo.c

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions php_phongo.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ extern zend_module_entry mongodb_module_entry;
# define PHONGO_API
#endif

#ifdef ZTS
# include "TSRM.h"
# define PHONGO_STREAM_CTX(x) x
#else
# define PHONGO_STREAM_CTX(x) NULL
#endif

ZEND_BEGIN_MODULE_GLOBALS(mongodb)
char *debug;
FILE *debug_fd;
Expand Down Expand Up @@ -102,23 +95,6 @@ typedef enum {
PHONGO_ERROR_LOGIC = 9
} php_phongo_error_domain_t;

typedef struct
{
void (*writer)(mongoc_stream_t *stream, int32_t timeout_msec, ssize_t sent, size_t iovcnt);
} php_phongo_stream_logger;

typedef struct
{
mongoc_stream_t vtable;
php_stream *stream;
const mongoc_uri_t *uri;
const mongoc_host_list_t *host;
#if ZTS
void ***tsrm_ls;
#endif
} php_phongo_stream_socket;


PHONGO_API zend_class_entry* phongo_exception_from_mongoc_domain(uint32_t /* mongoc_error_domain_t */ domain, uint32_t /* mongoc_error_code_t */ code);
PHONGO_API zend_class_entry* phongo_exception_from_phongo_domain(php_phongo_error_domain_t domain);
void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const char *format, ...)
Expand Down Expand Up @@ -146,7 +122,6 @@ bool phongo_execute_write (zval *manager, const char
int phongo_execute_command (zval *manager, const char *db, zval *zcommand, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
int phongo_execute_query (zval *manager, const char *namespace, zval *zquery, zval *zreadPreference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);

mongoc_stream_t* phongo_stream_initiator (const mongoc_uri_t *uri, const mongoc_host_list_t *host, void *user_data, bson_error_t *error);
const mongoc_read_concern_t* phongo_read_concern_from_zval (zval *zread_concern TSRMLS_DC);
const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference TSRMLS_DC);
const mongoc_write_concern_t* phongo_write_concern_from_zval (zval *zwrite_concern TSRMLS_DC);
Expand Down
1 change: 0 additions & 1 deletion php_phongo_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ typedef struct {
PHONGO_ZEND_OBJECT_PRE
mongoc_client_t *client;
char *pem_file;
PHONGO_STRUCT_ZVAL driverOptions;
PHONGO_ZEND_OBJECT_POST
} php_phongo_manager_t;

Expand Down
12 changes: 0 additions & 12 deletions src/MongoDB/Manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,6 @@ static void php_phongo_manager_free_object(phongo_free_object_arg *object TSRMLS
mongoc_client_destroy(intern->client);
}

if (intern->pem_file) {
efree(intern->pem_file);
}

#if PHP_VERSION_ID >= 70000
zval_ptr_dtor(&intern->driverOptions);
#else
if (intern->driverOptions) {
zval_ptr_dtor(&intern->driverOptions);
}
#endif

#if PHP_VERSION_ID < 70000
efree(intern);
#endif
Expand Down
8 changes: 3 additions & 5 deletions tests/connect/bug0720.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ require_once __DIR__ . "/../utils/basic.inc";
$SSL_DIR = realpath(__DIR__ . '/../../scripts/ssl/');

$driverOptions = [
'peer_name' => 'server',
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false,
'cafile' => $SSL_DIR . '/ca.pem', /* Defaults to openssl.cafile */
// libmongoc does not allow the hostname to be overridden as "server"
'allow_invalid_hostname' => true,
'ca_file' => $SSL_DIR . '/ca.pem',
];

$manager = new MongoDB\Driver\Manager(STANDALONE_SSL, ['ssl' => true], $driverOptions);
Expand Down
50 changes: 0 additions & 50 deletions tests/connect/standalone-ssl-0001.phpt

This file was deleted.

63 changes: 0 additions & 63 deletions tests/connect/standalone-ssl-0002.phpt

This file was deleted.

47 changes: 0 additions & 47 deletions tests/connect/standalone-ssl-0003.phpt

This file was deleted.

50 changes: 0 additions & 50 deletions tests/connect/standalone-ssl-0004.phpt

This file was deleted.

69 changes: 0 additions & 69 deletions tests/connect/standalone-ssl-0005.phpt

This file was deleted.

Loading