PDU use serial32 arithmetic for cmdsn, maxcmdsn and expcmdsn.

RFC3720 says that cmdsn comparison must be done using
serial32 arithmetic. This will definetly avoid a deadlock
if cmdsn wraps from 2^32-1 to 0.

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2012-11-28 10:37:28 +01:00
parent 700d363a88
commit cd09c0f17d
6 changed files with 30 additions and 9 deletions

View File

@@ -302,7 +302,7 @@ iscsi_which_events(struct iscsi_context *iscsi)
{
int events = iscsi->is_connected ? POLLIN : POLLOUT;
if (iscsi->outqueue && iscsi->outqueue->cmdsn <= iscsi->maxcmdsn) {
if (iscsi->outqueue && iscsi_serial32_compare(iscsi->outqueue->cmdsn,iscsi->maxcmdsn) <= 0) {
events |= POLLOUT;
}
return events;
@@ -442,7 +442,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
while (iscsi->outqueue) {
ssize_t total;
if (iscsi->outqueue->cmdsn > iscsi->maxcmdsn) {
if (iscsi_serial32_compare(iscsi->outqueue->cmdsn,iscsi->maxcmdsn) > 0) {
/* stop sending. maxcmdsn is reached */
return 0;
}