Skip to content
Start free evaluation

pdcomm_gem_program_respond

Function

Answers an incoming S7F1, F3, F5, F17, or F19 request.

PdcommStatus pdcomm_gem_program_respond(PdcommTcpEndpoint *endpoint, PdcommGemResult *result, uint32_t mode, uint8_t decision)

Declared in: #include <pdcomm_gem_programs.h>

result must be an unresponded #PDCOMM_GEM_PROGRAM_RECEIVED primary from this endpoint, generation, and HSMS selection, and its incoming reply slot must still be live. GEM must be Communicating. The original TCP event may already be destroyed.

  • **S7F1:** the library's fixed checks run first (existing program, capacity, invalid PPID, busy or reserved grants, and the mode against the store) and their PPGNT takes precedence. Otherwise decision 0 grants and 1 to 5 rejects with PPGNT 1 (already have), 2 (no space), 3 (invalid PPID), 4 (busy), or 5 (will not accept). A granted request activates a grant for mode only after the S7F2 entered the send queue.
  • **S7F3:** a program that does not fit the store limits is answered with ACKC7 3 (matrix overflow). Otherwise decision 1 to 5 rejects with ACKC7 1 (permission not granted), 2 (length error), 3 (matrix overflow), 4 (PPID not found), or 5 (mode unsupported). An accepted program can still be rejected by the library: ACKC7 1 when the grant policy requires a missing grant, 5 when another grant is active or the granted mode differs from mode, 2 when the body length differs from the granted LENGTH, 4 when REPLACE names a missing program, and 5 when CREATE names an existing one. An accepted program is installed and committed before the S7F4 is queued, and its grant is consumed.
  • **S7F5:** answered with S7F6 holding the stored program, or the unknown sentinel (empty PPID, empty Binary body). decision must be 0.
  • **S7F17:** decision 1 to 5 rejects as for S7F3; a request naming more PPIDs than max_request_ids is answered with ACKC7 3 (matrix overflow); a PPID that is not stored, including one longer than the store accepts, is answered with ACKC7 4 (PPID not found); while any grant is active the reply is ACKC7 5; a rejected request deletes nothing. Otherwise the listed programs (or all, for an empty list) are deleted and installed before the S7F18 is queued; a repeated PPID is deleted once.
  • **S7F19:** answered with S7F20 listing every stored PPID. decision must be 0.

The prepared reply is retained on the result before it is sent, so after #PDCOMM_BACKPRESSURE or a send failure applied can already be 1. Retry with the same mode and decision: the call sends only the retained reply and does not write again. After #PDCOMM_PROGRAM_UNCONFIRMED the installed change is kept but no acknowledgement is sent until pdcomm_gem_program_confirm_reply() accepts the uncertainty.

Parameters

NameDescription
endpointCommunicating GEM endpoint with a program store.
resultProgram request result from pdcomm_gem_handle_event(). Its reply_sent, acknowledgement, and processing fields are updated.
mode#PDCOMM_GEM_PROGRAM_CREATE, #PDCOMM_GEM_PROGRAM_REPLACE, or #PDCOMM_GEM_PROGRAM_UPSERT. Used by S7F1 and S7F3, but validated for every request.
decision0 to accept; 1 to 5 to reject S7F1, S7F3, or S7F17 as listed above; must be 0 for S7F5 and S7F19.

Returns

#PDCOMM_OK when the reply was queued; #PDCOMM_PROGRAM_UNCONFIRMED when the change was installed without a confirmed directory sync and no reply was sent; #PDCOMM_STALE_TOKEN when the result belongs to another endpoint, generation, or selection, was already answered, or its incoming slot is gone; #PDCOMM_INVALID_ARGUMENT for a NULL result, an invalid mode or decision, or a retry with a different mode or decision; #PDCOMM_INVALID_STATE when the result is not a program request, no program store is configured, or GEM is not Communicating; #PDCOMM_BACKPRESSURE when a staged TCP event is pending or the send queue is full; #PDCOMM_INVALID_DATA for a malformed request; a persistence error such as #PDCOMM_IO_ERROR (nothing installed, retry allowed); #PDCOMM_ALLOCATION_FAILED or #PDCOMM_POISONED.