I have not reproduce your test scenario, looking at code please see following comments:
If you check the function definition of pqsecure_raw_read() it actually do set errno like bellow
SOCK_ERRNO_SET(result_errno);
where result_errno = SOCK_ERRNO
Means anybody using those function pqsecure_raw_read/write, does not need to take care of portable ERRNO.
Regards
Umar Hayat
The new status of this patch is: Waiting on Author