         # File lib/em/protocols/postgres3.rb, line 152
    152:       def receive_data data
    153:         @data << data
    154:         while @data.length >= 5
    155:           pktlen = @data[1...5].unpack("N").first
    156:           if @data.length >= (1 + pktlen)
    157:             pkt = @data.slice!(0...(1+pktlen))
    158:             m = StringIO.open( pkt, "r" ) {|io| PostgresPR::Message.read( io ) }
    159:             if @pending_conn
    160:               dispatch_conn_message m
    161:             elsif @pending_query
    162:               dispatch_query_message m
    163:             else
    164:               raise "Unexpected message from database"
    165:             end
    166:           else
    167:             break # very important, break out of the while
    168:           end
    169:         end
    170:       end