Skip to content

Commit

Permalink
2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Browse files Browse the repository at this point in the history
	type cleanup for allmost all remaining files.
  • Loading branch information
tatsuhiro-t committed Mar 9, 2008
1 parent ca3f6e5 commit 032c7c2
Show file tree
Hide file tree
Showing 278 changed files with 1,489 additions and 1,517 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

type cleanup for allmost all remaining files.

2008-03-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Type clarification
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ bool AbstractCommand::execute() {
checkPoint.reset();
if(!_requestGroup->getPieceStorage().isNull()) {
_segments = _requestGroup->getSegmentMan()->getInFlightSegment(cuid);
int32_t maxSegments;
size_t maxSegments;
if(req->isKeepAlive() && e->option->get(PREF_ENABLE_HTTP_PIPELINING) == V_TRUE) {
maxSegments = e->option->getAsInt(PREF_MAX_HTTP_PIPELINING);
} else {
maxSegments = 1;
}
while((int32_t)_segments.size() < maxSegments) {
while(_segments.size() < maxSegments) {
SegmentHandle segment = _requestGroup->getSegmentMan()->getSegment(cuid);
if(segment.isNull()) {
break;
Expand Down Expand Up @@ -156,7 +156,7 @@ bool AbstractCommand::execute() {
logger->info(MSG_RESTARTING_DOWNLOAD, err, cuid, req->getUrl().c_str());
req->addTryCount();
bool isAbort = e->option->getAsInt(PREF_MAX_TRIES) != 0 &&
req->getTryCount() >= e->option->getAsInt(PREF_MAX_TRIES);
req->getTryCount() >= (unsigned int)e->option->getAsInt(PREF_MAX_TRIES);
if(isAbort) {
onAbort(err);
}
Expand Down Expand Up @@ -184,7 +184,7 @@ void AbstractCommand::tryReserved() {
e->addCommand(commands);
}

bool AbstractCommand::prepareForRetry(int32_t wait) {
bool AbstractCommand::prepareForRetry(time_t wait) {
if(!_requestGroup->getPieceStorage().isNull()) {
_requestGroup->getSegmentMan()->cancelSegment(cuid);
}
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class SocketCore;
class AbstractCommand : public Command, public RequestGroupAware {
private:
Time checkPoint;
int32_t timeout;
time_t timeout;
protected:
SharedHandle<Request> req;
DownloadEngine* e;
SharedHandle<SocketCore> socket;
std::deque<SharedHandle<Segment> > _segments;

void tryReserved();
virtual bool prepareForRetry(int32_t wait);
virtual bool prepareForRetry(time_t wait);
virtual void onAbort(Exception* ex);
virtual bool executeInternal() = 0;

Expand All @@ -76,7 +76,7 @@ class AbstractCommand : public Command, public RequestGroupAware {
void disableNameResolverCheck(const SharedHandle<NameResolver>& resolver);
virtual bool nameResolveFinished() const;
#endif // ENABLE_ASYNC_DNS
void setTimeout(int32_t timeout) { this->timeout = timeout; }
void setTimeout(time_t timeout) { this->timeout = timeout; }

void prepareForNextAction(Command* nextCommand = 0);

Expand Down
34 changes: 17 additions & 17 deletions src/AbstractDiskWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AbstractDiskWriter::~AbstractDiskWriter()
closeFile();
}

void AbstractDiskWriter::openFile(const std::string& filename, int64_t totalLength)
void AbstractDiskWriter::openFile(const std::string& filename, uint64_t totalLength)
{
File f(filename);
if(f.exists()) {
Expand All @@ -73,7 +73,7 @@ void AbstractDiskWriter::closeFile()
}

void AbstractDiskWriter::openExistingFile(const std::string& filename,
int64_t totalLength)
uint64_t totalLength)
{
this->filename = filename;
File f(filename);
Expand All @@ -86,7 +86,7 @@ void AbstractDiskWriter::openExistingFile(const std::string& filename,
}
}

void AbstractDiskWriter::createFile(const std::string& filename, int32_t addFlags)
void AbstractDiskWriter::createFile(const std::string& filename, int addFlags)
{
this->filename = filename;
assert(filename.size());
Expand All @@ -96,11 +96,11 @@ void AbstractDiskWriter::createFile(const std::string& filename, int32_t addFlag
}
}

int32_t AbstractDiskWriter::writeDataInternal(const unsigned char* data, int32_t len)
ssize_t AbstractDiskWriter::writeDataInternal(const unsigned char* data, size_t len)
{
int32_t writtenLength = 0;
while(writtenLength < len) {
int32_t ret = 0;
ssize_t writtenLength = 0;
while((size_t)writtenLength < len) {
ssize_t ret = 0;
while((ret = write(fd, data+writtenLength, len-writtenLength)) == -1 && errno == EINTR);
if(ret == -1) {
return -1;
Expand All @@ -110,39 +110,39 @@ int32_t AbstractDiskWriter::writeDataInternal(const unsigned char* data, int32_t
return writtenLength;
}

int32_t AbstractDiskWriter::readDataInternal(unsigned char* data, int32_t len)
ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len)
{
int32_t ret = 0;
ssize_t ret = 0;
while((ret = read(fd, data, len)) == -1 && errno == EINTR);
return ret;
}

void AbstractDiskWriter::seek(int64_t offset)
void AbstractDiskWriter::seek(off_t offset)
{
if(offset != lseek(fd, offset, SEEK_SET)) {
throw new DlAbortEx(EX_FILE_SEEK, filename.c_str(), strerror(errno));
}
}

void AbstractDiskWriter::writeData(const unsigned char* data, int32_t len, int64_t offset)
void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t offset)
{
seek(offset);
if(writeDataInternal(data, len) < 0) {
throw new DlAbortEx(EX_FILE_WRITE, filename.c_str(), strerror(errno));
}
}

int32_t AbstractDiskWriter::readData(unsigned char* data, int32_t len, int64_t offset)
ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, off_t offset)
{
int32_t ret;
ssize_t ret;
seek(offset);
if((ret = readDataInternal(data, len)) < 0) {
throw new DlAbortEx(EX_FILE_READ, filename.c_str(), strerror(errno));
}
return ret;
}

void AbstractDiskWriter::truncate(int64_t length)
void AbstractDiskWriter::truncate(uint64_t length)
{
if(fd == -1) {
throw new DlAbortEx("File not opened.");
Expand All @@ -151,7 +151,7 @@ void AbstractDiskWriter::truncate(int64_t length)
}

// TODO the file descriptor fd must be opened before calling this function.
int64_t AbstractDiskWriter::size() const
uint64_t AbstractDiskWriter::size() const
{
if(fd == -1) {
throw new DlAbortEx("File not opened.");
Expand All @@ -167,7 +167,7 @@ void AbstractDiskWriter::enableDirectIO()
{
#ifdef ENABLE_DIRECT_IO
if(_directIOAllowed) {
int32_t flg;
int flg;
while((flg = fcntl(fd, F_GETFL)) == -1 && errno == EINTR);
while(fcntl(fd, F_SETFL, flg|O_DIRECT) == -1 && errno == EINTR);
}
Expand All @@ -177,7 +177,7 @@ void AbstractDiskWriter::enableDirectIO()
void AbstractDiskWriter::disableDirectIO()
{
#ifdef ENABLE_DIRECT_IO
int32_t flg;
int flg;
while((flg = fcntl(fd, F_GETFL)) == -1 && errno == EINTR);
while(fcntl(fd, F_SETFL, flg&(~O_DIRECT)) == -1 && errno == EINTR);
#endif // ENABLE_DIRECT_IO
Expand Down
22 changes: 11 additions & 11 deletions src/AbstractDiskWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,34 @@ class Logger;
class AbstractDiskWriter : public DiskWriter {
protected:
std::string filename;
int32_t fd;
int fd;
const Logger* logger;

void createFile(const std::string& filename, int32_t addFlags = 0);
void createFile(const std::string& filename, int addFlags = 0);

private:
int32_t writeDataInternal(const unsigned char* data, int32_t len);
int32_t readDataInternal(unsigned char* data, int32_t len);
ssize_t writeDataInternal(const unsigned char* data, size_t len);
ssize_t readDataInternal(unsigned char* data, size_t len);

void seek(int64_t offset);
void seek(off_t offset);

public:
AbstractDiskWriter();
virtual ~AbstractDiskWriter();

virtual void openFile(const std::string& filename, int64_t totalLength = 0);
virtual void openFile(const std::string& filename, uint64_t totalLength = 0);

virtual void closeFile();

virtual void openExistingFile(const std::string& filename, int64_t totalLength = 0);
virtual void openExistingFile(const std::string& filename, uint64_t totalLength = 0);

virtual void writeData(const unsigned char* data, int32_t len, int64_t offset);
virtual void writeData(const unsigned char* data, size_t len, off_t offset);

virtual int32_t readData(unsigned char* data, int32_t len, int64_t offset);
virtual ssize_t readData(unsigned char* data, size_t len, off_t offset);

virtual void truncate(int64_t length);
virtual void truncate(uint64_t length);

virtual int64_t size() const;
virtual uint64_t size() const;

virtual void enableDirectIO();

Expand Down
12 changes: 6 additions & 6 deletions src/AbstractSingleDiskAdaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ void AbstractSingleDiskAdaptor::openExistingFile()
diskWriter->openExistingFile(getFilePath(), totalLength);
}

void AbstractSingleDiskAdaptor::writeData(const unsigned char* data, int32_t len, int64_t offset)
void AbstractSingleDiskAdaptor::writeData(const unsigned char* data, size_t len, off_t offset)
{
diskWriter->writeData(data, len, offset);
}

int32_t AbstractSingleDiskAdaptor::readData(unsigned char* data, int32_t len, int64_t offset)
ssize_t AbstractSingleDiskAdaptor::readData(unsigned char* data, size_t len, off_t offset)
{
return diskWriter->readData(data, len, offset);
}
Expand All @@ -80,12 +80,12 @@ bool AbstractSingleDiskAdaptor::fileExists()
return File(getFilePath()).exists();
}

int64_t AbstractSingleDiskAdaptor::size() const
uint64_t AbstractSingleDiskAdaptor::size() const
{
return diskWriter->size();
}

void AbstractSingleDiskAdaptor::truncate(int64_t length)
void AbstractSingleDiskAdaptor::truncate(uint64_t length)
{
diskWriter->truncate(length);
}
Expand Down Expand Up @@ -123,12 +123,12 @@ DiskWriterHandle AbstractSingleDiskAdaptor::getDiskWriter() const
return diskWriter;
}

void AbstractSingleDiskAdaptor::setTotalLength(const int64_t& totalLength)
void AbstractSingleDiskAdaptor::setTotalLength(const uint64_t& totalLength)
{
this->totalLength = totalLength;
}

int64_t AbstractSingleDiskAdaptor::getTotalLength() const
uint64_t AbstractSingleDiskAdaptor::getTotalLength() const
{
return totalLength;
}
Expand Down
16 changes: 8 additions & 8 deletions src/AbstractSingleDiskAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FileAllocationIterator;
class AbstractSingleDiskAdaptor : public DiskAdaptor {
protected:
SharedHandle<DiskWriter> diskWriter;
int64_t totalLength;
uint64_t totalLength;
public:
AbstractSingleDiskAdaptor();

Expand All @@ -59,16 +59,16 @@ class AbstractSingleDiskAdaptor : public DiskAdaptor {

virtual void openExistingFile();

virtual void writeData(const unsigned char* data, int32_t len,
int64_t offset);
virtual void writeData(const unsigned char* data, size_t len,
off_t offset);

virtual int32_t readData(unsigned char* data, int32_t len, int64_t offset);
virtual ssize_t readData(unsigned char* data, size_t len, off_t offset);

virtual bool fileExists();

virtual int64_t size() const;
virtual uint64_t size() const;

virtual void truncate(int64_t length);
virtual void truncate(uint64_t length);

virtual SharedHandle<FileAllocationIterator> fileAllocationIterator();

Expand All @@ -82,9 +82,9 @@ class AbstractSingleDiskAdaptor : public DiskAdaptor {

SharedHandle<DiskWriter> getDiskWriter() const;

void setTotalLength(const int64_t& totalLength);
void setTotalLength(const uint64_t& totalLength);

int64_t getTotalLength() const;
uint64_t getTotalLength() const;
};

} // namespace aria2
Expand Down
4 changes: 2 additions & 2 deletions src/ActivePeerConnectionCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
RequestGroup* requestGroup,
DownloadEngine* e,
const BtContextHandle& btContext,
int32_t interval)
time_t interval)
:Command(cuid),
BtContextAwareCommand(btContext),
RequestGroupAware(requestGroup),
Expand All @@ -62,7 +62,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
_thresholdSpeed(SLOW_SPEED_THRESHOLD),
_numNewConnection(5)
{
int32_t maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
if(maxDownloadSpeed > 0) {
_thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
}
Expand Down
12 changes: 6 additions & 6 deletions src/ActivePeerConnectionCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,30 @@ class ActivePeerConnectionCommand : public Command,
public RequestGroupAware
{
private:
int32_t interval; // UNIT: sec
time_t interval; // UNIT: sec
DownloadEngine* e;
Time checkPoint;
int32_t _thresholdSpeed; // UNIT: byte/sec
int32_t _numNewConnection; // the number of the connection to establish.
unsigned int _thresholdSpeed; // UNIT: byte/sec
size_t _numNewConnection; // the number of the connection to establish.
public:
ActivePeerConnectionCommand(int cuid,
RequestGroup* requestGroup,
DownloadEngine* e,
const SharedHandle<BtContext>& btContext,
int32_t interval);
time_t interval);

virtual ~ActivePeerConnectionCommand();

virtual bool execute();

void connectToPeer(const SharedHandle<Peer>& peer);

void setThresholdSpeed(int32_t speed)
void setThresholdSpeed(unsigned int speed)
{
_thresholdSpeed = speed;
}

void setNumNewConnection(int32_t numNewConnection)
void setNumNewConnection(size_t numNewConnection)
{
_numNewConnection = numNewConnection;
}
Expand Down
Loading

0 comments on commit 032c7c2

Please sign in to comment.