If the DCB is closed in handleError, it would be NULL in closeSession. To only close the DCB in one place, the handleError can be reduced to writing an error to the client and marking the failure as a fatal one.