Commit Graph

219 Commits

Author SHA1 Message Date
Hannes Magnusson 60fdf52e1d PHPC-241: mongodb.debug improvements 2015-04-24 11:51:09 -07:00
Hannes Magnusson 6cbacda4ac Fix unused result warning - and use the localtime in logs 2015-04-24 10:09:49 -07:00
Hannes Magnusson ebc15aefea PHPC-266: Add MongoDB\Driver\UnexpectedValueException 2015-04-23 16:13:35 -07:00
Hannes Magnusson 8d5e5d87c9 Bump copyright -- happy 2015 2015-04-23 10:16:20 -07:00
Hannes Magnusson c286209cae PHPC-241: Include lib versions and uri in the logs 2015-04-21 12:44:21 -07:00
Hannes Magnusson bcf3d9b96b Use the pretty MONGOC macros 2015-04-21 12:44:21 -07:00
Hannes Magnusson 6d7193d2c1 Move the init function to where all the others are and add folding markers 2015-04-21 12:44:20 -07:00
Jeremy Mikola 70b711000f Current element is already freed in php_phongo_cursor_free()
php_phongo_cursor_iterator_dtor() should not need to free the current element, which is stored on our cursor struct. If the cursor is only used by one iterator, zval_ptr_dtor() on the iterator's intern.data property (i.e. our Cursor zval) will implicitly call the free_object handler, which will invoke php_phongo_cursor_free() and clear the current element.
2015-04-21 14:23:16 -04:00
Jeremy Mikola f176cb7d91 Test Cursor iteration handlers and ensure rewind doesn't reset position 2015-04-21 14:23:16 -04:00
Jeremy Mikola c7b7891697 PHPC-240: Rely on libmongoc for command cursor iteration
libmongoc already provides a mechanism to upgrade a cursor with a single command result document into a command cursor, which will seamlessly iterate through the first batch and documents returned by successive getmore ops.

This allows us to remove our own "first batch" handling and simplify the move_forward and rewind iteration handlers.
2015-04-21 14:23:16 -04:00
Hannes Magnusson f40aa95670 PHPC-254: Remove unused RINIT and RSHUTDOWN handlers 2015-04-21 10:30:25 -07:00
Hannes Magnusson f4de8a4249 PHPC-243: Manager->executeUpdate() option is supposed to be 'multi' 2015-04-14 15:15:35 -07:00
Hannes Magnusson 251ed3ef39 PHPC-239: Cursor refcount issues
This also fixes re-iterating over a cursor where we would not free the
firstBatch properly, so the last result was still there.
2015-04-14 11:45:33 -07:00
Hannes Magnusson 930ff02098 PHPC-236: 5.3-zts build broken 2015-04-10 15:51:48 -07:00
Hannes Magnusson 0562092ef1 Simplify hash and fix windows build 2015-04-09 15:17:35 -07:00
Hannes Magnusson d1e937794d Rename the compat header - its much more then PHP5.3 issues now 2015-04-09 15:11:59 -07:00
Hannes Magnusson c6d29b3220 Fix warning, return in noreturn function 2015-04-09 15:09:30 -07:00
Hannes Magnusson 68caa686ba Fix zts build 2015-04-09 15:09:19 -07:00
Hannes Magnusson 5494b86255 Apparently there is a function for this! 2015-04-08 14:40:45 -07:00
Hannes Magnusson 6d8f7e9ed2 Fix zts build.. TSRMLS_FETCH_FROM_CTX declares variables and therefore must come first 2015-04-08 12:59:38 -07:00
Hannes Magnusson 69fe06ace8 Remove noop log handler 2015-04-08 12:58:05 -07:00
Hannes Magnusson 0ea1c5e863 PHPC-231: Manager instances should not free streams that are still in use 2015-04-08 12:58:05 -07:00
Jeremy Mikola c32a7cc646 Remove unnecessary php_phongo_cursor_free_current() call
The current element is already freed at the top of this function. After that point, the element could only be intialized from first_batch_iter (after which we return immediately) or if mongoc_cursor_next() returns true (in which case we wouldn't be in this else clause).
2015-04-06 17:31:56 -04:00
Jeremy Mikola efd91816da Re-use cursor_free_current() in cursor_free()
With this change, all visitor_data.zchild freeing is now done through the same function.
2015-04-06 17:30:21 -04:00
Jeremy Mikola c454d27d95 PHPC-215: Fix Cursor iteration through IteratorIterator
This removes the invalidate_current handler. Due to SPL's implementation, our handler was being invoked between rewinding and checking if the current position was valid. Given that our validity check depends on inspecting a pointer to the current element (like MySQLi's result iterator), we cannot use invalidate_current.

The current element must still be freed during iteration, so we will instead call a php_phongo_cursor_free_current() function as needed. Additionally, we should track a reference to the Cursor object zval on the iterator itself, which will ensure it is not garbage-collected during iteration (demonstrated in the segfault backtrace in PHPC-215).

Lastly, this commit renames the Cursor object and iterator structs and related functions to be more consistent with implementions in PHP core.
2015-04-06 15:45:19 -04:00
Jeremy Mikola 66193e83bc PHPC-224: Consolidate Result and Cursor classes into one
This class is now simply Traversable (no longer IteratorAggregate) and adds isDead() and getId() methods from the original Cursor class.
2015-04-06 15:45:19 -04:00
Hannes Magnusson 1ab97b3bc3 PHPC-191 && PHPC-192: Add verify_expiry && verify_peer_name certificate verify options 2015-04-03 12:19:44 -07:00
Hannes Magnusson ee9e33148a PHPC-223: Use explicit SSL options rather then stream context
This also adds support for PHPC-185
2015-04-02 16:15:22 -07:00
Hannes Magnusson 22ca99673b Fix setting debug logging as part of the driverOptions 2015-04-02 16:12:52 -07:00
Hannes Magnusson e1e763f88b Fix compile warning on 32bit 2015-04-01 16:15:48 -07:00
Hannes Magnusson ab8d22c7ff PHPC-219 - BSON\Javascript segfaults on Ubuntu Precise 32bit 2015-04-01 14:52:24 -07:00
Jeremy Mikola 1f9f7716d9 PHPC-214: Result does not need custom iterator classes
Wrapping a cursor can already be accomplished with IteratorIterator.
2015-03-31 15:29:19 -04:00
Hannes Magnusson eb3aa9f939 PHPC-216: PHP5.5 change the prototype of get_current_key leading to
very strange and hard to track down segfaults
2015-03-30 17:03:29 -07:00
Hannes Magnusson 48d96546f9 PHPC-175: Fix header includes on Windows 2015-03-25 13:40:38 -07:00
Hannes Magnusson 3b78578ba3 Allow mongoc_init() to not use our mm
There is a shutdown race condition in the mongoc counters segment
allocation where zend mm will free the counters during RSHUTDOWN.
This happens as there is no "persistent alloc" callback from the bson
allocators that we can pemalloc() for.
Instead, we'll let mongoc_init use its own alloctors -- but we have to
remember to reset the alloc callbacks before mongoc_cleanup()
2015-03-25 13:22:37 -07:00
Hannes Magnusson c5a0711972 PHPC-200: Don't set stream initiator when creating client fails 2015-03-25 08:55:30 -07:00
Hannes Magnusson c21eb74f29 Simplify
It originally was used for more then just plain result, but now we
always have the cursor so no need to pass the server_id
2015-03-24 09:31:50 -07:00
Hannes Magnusson 809e99d7b8 PHPC-174: Rename module registration, constants and so on to mongodb 2015-03-23 16:37:38 -07:00
Hannes Magnusson 4daeefa3a5 Remove char * casting, the macro soup leads to incorrect sizeof 2015-03-23 12:46:55 -07:00
Hannes Magnusson 7ccd38c870 Fix zts 2015-03-20 16:49:34 -07:00
Hannes Magnusson b40a98e677 PHPC-183: Fix compiler warnings with -Wdeclaration-after-statement
This also increases the chances of successful Windows build :)
2015-03-20 15:37:24 -07:00
Hannes Magnusson 5f8d990b53 PHPC-24 PHPC-77 PHPC-69 Provide a functioning Server object 2015-03-20 11:33:46 -07:00
Hannes Magnusson d53c90ce94 PHPC-106: Connect asynchronouslyish 2015-03-19 14:20:44 -07:00
Hannes Magnusson b825395d18 PHPC-106: Implement the new poll callback 2015-03-19 14:20:44 -07:00
Hannes Magnusson 50fe097841 Store the original mongoc_uri_t not just the options bson 2015-03-19 14:20:44 -07:00
Hannes Magnusson 14533db5d8 Add a little tracing love 2015-03-18 11:50:35 -07:00
Hannes Magnusson 57ed2c92fb Properly block on socket writes
If a socket write returns EWOULDBLOCK PHP will poll() using the socket
read timeout.
This is only an issue when writing crazy amount of data to a
non-blocking socket in multiple iterations... which we do.
2015-03-18 11:40:04 -07:00
Hannes Magnusson ddc558e32a Fix null pointer exception 2015-03-18 11:39:14 -07:00
Hannes Magnusson b6b6e9636f Unhide this 2015-03-18 11:30:26 -07:00
Jeremy Mikola aa5903790a Return const struct pointers from zval getters 2015-03-17 16:17:24 -04:00