The Room class moves to src/room/php_room.c - #165
Merged
Conversation
http_server_class.c carried the whole PHP object layer over rooms — the Room class with its handlers and transfer_obj, the helpers, and the six HttpServer methods that address a room by name. That is 850 lines of a subsystem the server only owns a hub of, in a file that is already the largest in the tree. The server object stays opaque: the moved code reaches it through two pinpoint accessors, http_server_is_running() and http_server_topic_hub_ensure(), which is the pattern src/http3/ already uses. The ensure accessor is now the only place a hub is created, so the worker-clone rule is stated once instead of at two of three call sites. php_room.c compiles in every configuration, because the generated arginfo registers those six HttpServer methods whether or not WebSocket is built: a --disable-websocket build that omitted the file linked cleanly and then failed at dlopen with an undefined symbol.
Contributor
CoverageTotal lines: 82.32% → 82.19% (-0.12 pp)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
http_server_class.ccarried the whole PHP object layer over rooms: theRoomclass with its object handlers and
transfer_obj, the delivery/knob helpers, andthe six
HttpServermethods that address a room by name — 850 lines of asubsystem the server owns only a hub of, in the largest file in the tree. They
move to
src/room/php_room.c, beside the core they drive.The move is verbatim. Four substitutions were applied to the moved text, because
http_server_object's layout is private tohttp_server_class.c:The last two are new pinpoint accessors, declared in
php_http_server.h— thepattern
src/http3/already uses against the same opaque struct.http_server_topic_hub_ensure()is now the only place a hub is created, andthe worker-clone rule that used to be spelled at one of the three creation sites
and omitted at another is stated once, inside it. A clone inherits its parent's
hub through the transfer shell; one minted on a clone would be attached by
nobody, and every publish through it would report
served=0with nothing to showfor it.
What review caught, and it was not visible from any green build
php_room.cfirst went intoconfig.m4inside thePHP_WEBSOCKET=yesblock,where its neighbours live. But the generated
HttpServer.php_arginfo.hregistersall six room methods unconditionally, so a
--disable-websocketbuild linkedcleanly — a shared object may carry undefined symbols — and then failed at
dlopen:The file is in the unconditional source list now. Measured after the fix, in a
separate build tree:
--disable-websocketcompiles with no warnings,nm -ushows no undefined symbol of ours, the extension loads, and
class_exists('TrueAsync\Room')is correctlyfalsewhileTrueAsync\HttpServeristrue.No CI job builds
--disable-websocket. That is S6.4's business, and this is thesecond finding in two steps that only a build of that configuration could reach.
Also taken from the review: the
ensure()comment claimed an exclusivity it didnot have;
php_room_minit()'s stated MINIT dependency was on a class it does nottouch, while the real one —
room_delivery_exception_ce, registered earlier byws_php_classes_register()— was unwritten; and three pieces of dead scaffoldingwent (an empty
#ifdef/#endifpair, a NULL check the accessor already makes, anunused include).
Left deliberately
RoomDeliveryException's stub declares itextends WebSocketException, sophp_room.cstill includeswebsocket/php_websocket.hfor its class entry, andevery
send()/trySend()failure path goes through it. Giving that exception abase of its own is a PHP-visible contract change, not a file move; the file header
names it as the blocker where the next step will hit it.
Measured
phpize && ./configure && make -j12: no warnings of ours;nm -uclean.tests/phpt: 381 passed, 0 failed, 1 warned (an XFAIL section on a passingtest, pre-existing).
tests/valgrind-rooms.sh: 9 tests, 0 leaked.gen_stub.phpversion hash differs locally, so nothing is committed there).