App proxy how to handle when flow/connection/session data read empty

Hi there,

With app proxy, when in case flow read, tcp connection read or udp session read empty is encountered.

In this case, should I return directly, or close flow, connection, session and then return, or should I go on write through the empty data as usual even if it is empty?

Put below the code example in case of flow read and connection write.

     flow.readData { data, readError in
      guard readError == nil, let readData = data else {
				log.error("[LogApp] Failed to read data from the TCP flow \(self.local.debugDescription)")
         
		local.closeWriteWithError(readError)
		local.closeReadWithError(readError)
        return
      }
       
      guard !readData.isEmpty else {
				log.verbose("[LogApp] Empty data from TCP flow \(self.local.description)")
      // What should I do here?
      // return directly
      // or close flow and return
      // or keep on going to connection write?
      }

      connection.send(content: data, completion: .contentProcessed( { connectionError in
...
         }))

Thanks in advance for any suggestion.

In this case, should I return directly, or close flow, connection, session and then return, or should I go on write through the empty data as usual even if it is empty?

Close the flow or connection, or whichever side received the EOF first and then propagate a closed state to the other side so the flow or connection can be tore down also and then return. This could be done with a copier state update handler that is propagating state for both sides of the connection (local flow and remote side of connection).

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

This could be done with a copier state update handler that is propagating state for both sides of the connection (local flow and remote side of connection).

Currently it is done like that: any EOF read back, will close both sides flow and connection (session). Does it matter to simplify like that?

For your update handler to propagate state, do you have any example code for a reference?

Thanks in advance for any suggestion.

App proxy how to handle when flow/connection/session data read empty
 
 
Q