From: wessels <> Date: Wed, 31 Jan 2007 14:13:54 +0000 (+0000) Subject: Two versions of DiskdIOStrategy::send() had a lot of duplicated code. X-Git-Tag: SQUID_3_0_PRE6~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f30dcf2af25dfc4ba2c866cc7df12035a6a91b8c;p=thirdparty%2Fsquid.git Two versions of DiskdIOStrategy::send() had a lot of duplicated code. This patch moves the common code to DiskdIOStrategy::SEND(). --- diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index a1030db404..8819ba30d4 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskdIOStrategy.cc,v 1.5 2006/09/03 18:47:18 serassio Exp $ + * $Id: DiskdIOStrategy.cc,v 1.6 2007/01/31 07:13:54 wessels Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -348,109 +348,59 @@ DiskdIOStrategy::handle(diomsg * M) int DiskdIOStrategy::send(int mtype, int id, DiskdFile *theFile, int size, int offset, off_t shm_offset, RefCountable_ *requestor) { - int x; diomsg M; - static int send_errors = 0; - static int last_seq_no = 0; - static int seq_no = 0; - M.mtype = mtype; M.callback_data = cbdataReference(theFile); theFile->RefCountReference(); M.requestor = requestor; + M.newstyle = true; if (requestor) requestor->RefCountReference(); - M.size = size; - - M.offset = offset; - - M.status = -1; - - M.shm_offset = (int) shm_offset; - - M.id = id; - - M.seq_no = ++seq_no; - - M.newstyle = true; - - if (M.seq_no < last_seq_no) - debug(79, 1) ("WARNING: sequencing out of order\n"); - - debugs (79,9, "sending with" << smsgid <<" " << &M << " " < magic2) { - select(0, NULL, NULL, NULL, &delay); - Store::Root().callback(); - - if (delay.tv_usec < 1000000) - delay.tv_usec <<= 1; - } - - return x; + return SEND(&M, mtype, id, size, offset, shm_offset); } int DiskdIOStrategy::send(int mtype, int id, StoreIOState::Pointer sio, int size, int offset, off_t shm_offset) { - int x; diomsg M; + M.callback_data = cbdataReference(sio.getRaw()); + M.newstyle = false; + + return SEND(&M, mtype, id, size, offset, shm_offset); +} + +int +DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, int size, int offset, off_t shm_offset) +{ static int send_errors = 0; static int last_seq_no = 0; static int seq_no = 0; - M.mtype = mtype; - M.callback_data = cbdataReference(sio.getRaw()); - M.size = size; - M.offset = offset; - M.status = -1; - M.shm_offset = (int) shm_offset; - M.id = id; - M.seq_no = ++seq_no; - M.newstyle = false; + int x; + + M->mtype = mtype; + M->size = size; + M->offset = offset; + M->status = -1; + M->shm_offset = (int) shm_offset; + M->id = id; + M->seq_no = ++seq_no; - if (M.seq_no < last_seq_no) + if (M->seq_no < last_seq_no) debug(79, 1) ("WARNING: sequencing out of order\n"); - x = msgsnd(smsgid, &M, diomsg::msg_snd_rcv_sz, IPC_NOWAIT); + x = msgsnd(smsgid, M, diomsg::msg_snd_rcv_sz, IPC_NOWAIT); - last_seq_no = M.seq_no; + last_seq_no = M->seq_no; if (0 == x) { diskd_stats.sent_count++; away++; } else { debug(79, 1) ("storeDiskdSend: msgsnd: %s\n", xstrerror()); - cbdataReferenceDone(M.callback_data); + cbdataReferenceDone(M->callback_data); assert(++send_errors < 100); + shm.put (shm_offset); } /* diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.h b/src/DiskIO/DiskDaemon/DiskdIOStrategy.h index b1f5b49cec..7d21790b20 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.h +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.h @@ -1,6 +1,6 @@ /* - * $Id: DiskdIOStrategy.h,v 1.2 2006/05/22 19:58:51 wessels Exp $ + * $Id: DiskdIOStrategy.h,v 1.3 2007/01/31 07:13:54 wessels Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -103,6 +103,7 @@ private: bool optionQ2Parse(char const *option, const char *value, int reconfiguring); void optionQ2Dump(StoreEntry * e) const; int send(int mtype, int id, RefCount sio, int size, int offset, off_t shm_offset); + int SEND(diomsg * M, int mtype, int id, int size, int offset, off_t shm_offset); void handle(diomsg * M); void unlinkDone(diomsg * M); int magic1;