MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / deliver_request

Method deliver_request

src/jrd/event.cpp:838–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836
837
838void EventManager::deliver_request(evt_req* request)
839{
840/**************************************
841 *
842 * d e l i v e r _ r e q u e s t
843 *
844 **************************************
845 *
846 * Functional description
847 * Request has been satisfied, send updated event block to user, then
848 * Clean up request.
849 *
850 **************************************/
851 HalfStaticArray<UCHAR, BUFFER_MEDIUM> buffer;
852 UCHAR* p = buffer.getBuffer(1);
853
854 IEventCallback* ast = request->req_ast;
855
856 *p++ = EPB_version1;
857
858 // Loop thru interest block picking up event name, counts, and unlinking stuff
859
860 try
861 {
862 req_int* interest;
863 for (SRQ_PTR next = request->req_interests;
864 next && (interest = (req_int*) SRQ_ABS_PTR(next));
865 next = interest->rint_next)
866 {
867 //interest = (req_int*) SRQ_ABS_PTR(next); same line as in the condition above
868 evnt* const event = (evnt*) SRQ_ABS_PTR(interest->rint_event);
869
870 const FB_SIZE_T length = buffer.getCount();
871 const FB_SIZE_T extent = event->evnt_length + sizeof(UCHAR) + sizeof(SLONG);
872
873 if (length + extent > MAX_USHORT)
874 {
875 BadAlloc::raise();
876 }
877
878 buffer.grow(length + extent);
879 p = buffer.begin() + length;
880
881 *p++ = event->evnt_length;
882 memcpy(p, event->evnt_name, event->evnt_length);
883 p += event->evnt_length;
884 const SLONG count = event->evnt_count + 1;
885 *p++ = (UCHAR) (count);
886 *p++ = (UCHAR) (count >> 8);
887 *p++ = (UCHAR) (count >> 16);
888 *p++ = (UCHAR) (count >> 24);
889 }
890 }
891 catch (const BadAlloc&)
892 {
893 gds__log("Out of memory. Failed to post all events.");
894 }
895

Callers

nothing calls this directly

Calls 6

raiseFunction · 0.85
getBufferMethod · 0.45
getCountMethod · 0.45
growMethod · 0.45
beginMethod · 0.45
eventCallbackFunctionMethod · 0.45

Tested by

no test coverage detected