improve read_packet somewhat to properly drain the ssl pending buffer