No, the modification introduces an error. The problem is that nqueue is decremented before the array entry dg[iget] is processed, allowing the signal handler to read a new datagram into this array element.