Some fixes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
aa905a66a1
commit
f679e95b10
|
@ -16,6 +16,15 @@
|
||||||
#include "RPartition.h"
|
#include "RPartition.h"
|
||||||
#include "RSession.h"
|
#include "RSession.h"
|
||||||
|
|
||||||
|
// print_time
|
||||||
|
void
|
||||||
|
print_time(const char *format, bigtime_t &time)
|
||||||
|
{
|
||||||
|
bigtime_t lastTime = time;
|
||||||
|
time = system_time();
|
||||||
|
printf("%lld: %s took: %lld us\n", time, format, time - lastTime);
|
||||||
|
}
|
||||||
|
|
||||||
// priorities of the different message kinds
|
// priorities of the different message kinds
|
||||||
enum {
|
enum {
|
||||||
REQUEST_PRIORITY = 0,
|
REQUEST_PRIORITY = 0,
|
||||||
|
@ -81,10 +90,15 @@ DiskDeviceManager::MessageReceived(BMessage *message)
|
||||||
case B_REG_NEXT_DISK_DEVICE:
|
case B_REG_NEXT_DISK_DEVICE:
|
||||||
case B_REG_GET_DISK_DEVICE:
|
case B_REG_GET_DISK_DEVICE:
|
||||||
case B_REG_UPDATE_DISK_DEVICE:
|
case B_REG_UPDATE_DISK_DEVICE:
|
||||||
|
{
|
||||||
|
bigtime_t time = system_time();
|
||||||
|
print_time("getting message", time);
|
||||||
DetachCurrentMessage();
|
DetachCurrentMessage();
|
||||||
if (!_PushMessage(message, REQUEST_PRIORITY))
|
if (!_PushMessage(message, REQUEST_PRIORITY))
|
||||||
delete message;
|
delete message;
|
||||||
|
print_time("pushing message into priority queue", time);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case B_REG_DEVICE_START_WATCHING:
|
case B_REG_DEVICE_START_WATCHING:
|
||||||
case B_REG_DEVICE_STOP_WATCHING:
|
case B_REG_DEVICE_STOP_WATCHING:
|
||||||
DetachCurrentMessage();
|
DetachCurrentMessage();
|
||||||
|
@ -141,8 +155,10 @@ DiskDeviceManager::_NextDiskDeviceRequest(BMessage *request)
|
||||||
void
|
void
|
||||||
DiskDeviceManager::_GetDiskDeviceRequest(BMessage *request)
|
DiskDeviceManager::_GetDiskDeviceRequest(BMessage *request)
|
||||||
{
|
{
|
||||||
|
bigtime_t time = system_time();
|
||||||
Lock();
|
Lock();
|
||||||
status_t error = B_ENTRY_NOT_FOUND;
|
print_time("locking", time);
|
||||||
|
status_t error = B_OK;
|
||||||
// get the device
|
// get the device
|
||||||
RDiskDevice *device = NULL;
|
RDiskDevice *device = NULL;
|
||||||
int32 id = 0;
|
int32 id = 0;
|
||||||
|
@ -156,6 +172,7 @@ DiskDeviceManager::_GetDiskDeviceRequest(BMessage *request)
|
||||||
device = partition->Device();
|
device = partition->Device();
|
||||||
} else
|
} else
|
||||||
error = B_BAD_VALUE;
|
error = B_BAD_VALUE;
|
||||||
|
print_time("finding device", time);
|
||||||
// archive device and add it to the reply message
|
// archive device and add it to the reply message
|
||||||
BMessage reply(B_REG_RESULT);
|
BMessage reply(B_REG_RESULT);
|
||||||
if (device) {
|
if (device) {
|
||||||
|
@ -163,11 +180,15 @@ DiskDeviceManager::_GetDiskDeviceRequest(BMessage *request)
|
||||||
error = device->Archive(&deviceArchive);
|
error = device->Archive(&deviceArchive);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = reply.AddMessage("device", &deviceArchive);
|
error = reply.AddMessage("device", &deviceArchive);
|
||||||
}
|
} else // requested object not found
|
||||||
|
error = B_ENTRY_NOT_FOUND;
|
||||||
|
print_time("archiving device", time);
|
||||||
// add result and send reply
|
// add result and send reply
|
||||||
reply.AddInt32("result", error);
|
reply.AddInt32("result", error);
|
||||||
request->SendReply(&reply);
|
request->SendReply(&reply);
|
||||||
|
print_time("sending reply", time);
|
||||||
Unlock();
|
Unlock();
|
||||||
|
print_time("unlocking", time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _UpdateDiskDeviceRequest
|
// _UpdateDiskDeviceRequest
|
||||||
|
@ -175,7 +196,7 @@ void
|
||||||
DiskDeviceManager::_UpdateDiskDeviceRequest(BMessage *request)
|
DiskDeviceManager::_UpdateDiskDeviceRequest(BMessage *request)
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
status_t error = B_ENTRY_NOT_FOUND;
|
status_t error = B_OK;
|
||||||
// get the device and check the object is up to date
|
// get the device and check the object is up to date
|
||||||
bool upToDate = false;
|
bool upToDate = false;
|
||||||
RDiskDevice *device = NULL;
|
RDiskDevice *device = NULL;
|
||||||
|
@ -190,6 +211,8 @@ DiskDeviceManager::_UpdateDiskDeviceRequest(BMessage *request)
|
||||||
device = fDeviceList.DeviceWithID(id);
|
device = fDeviceList.DeviceWithID(id);
|
||||||
if (device)
|
if (device)
|
||||||
upToDate = (device->ChangeCounter() == changeCounter);
|
upToDate = (device->ChangeCounter() == changeCounter);
|
||||||
|
PRINT(("DiskDeviceManager::_UpdateDiskDeviceRequest(): device id: %ld, "
|
||||||
|
"device: %p\n", id, device));
|
||||||
} else if (request->FindInt32("session_id", &id) == B_OK) {
|
} else if (request->FindInt32("session_id", &id) == B_OK) {
|
||||||
if (RSession *session = fDeviceList.SessionWithID(id)) {
|
if (RSession *session = fDeviceList.SessionWithID(id)) {
|
||||||
device = session->Device();
|
device = session->Device();
|
||||||
|
@ -213,7 +236,8 @@ DiskDeviceManager::_UpdateDiskDeviceRequest(BMessage *request)
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = reply.AddMessage("device", &deviceArchive);
|
error = reply.AddMessage("device", &deviceArchive);
|
||||||
}
|
}
|
||||||
}
|
} else // requested object not found
|
||||||
|
error = B_ENTRY_NOT_FOUND;
|
||||||
// add result and send reply
|
// add result and send reply
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = reply.AddBool("up_to_date", upToDate);
|
error = reply.AddBool("up_to_date", upToDate);
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
int32 Count() const { return fCount; }
|
int32 Count() const { return fCount; }
|
||||||
|
|
||||||
bool Lock() { fLocked++; return true; }
|
bool Lock() { fLocked++; return true; }
|
||||||
void Unlock() { if (fLocked > 0) fLocked--; }
|
void Unlock() { if (fLocked > 0 && --fLocked == 0) fChanged = false; }
|
||||||
bool IsLocked() const { return (fLocked > 0); }
|
bool IsLocked() const { return (fLocked > 0); }
|
||||||
|
|
||||||
bool Increment()
|
bool Increment()
|
||||||
|
|
|
@ -18,6 +18,7 @@ class RDiskDeviceList;
|
||||||
class RPartition;
|
class RPartition;
|
||||||
class RSession;
|
class RSession;
|
||||||
|
|
||||||
|
#include "Debug.h"
|
||||||
class RDiskDevice {
|
class RDiskDevice {
|
||||||
public:
|
public:
|
||||||
RDiskDevice();
|
RDiskDevice();
|
||||||
|
@ -36,7 +37,8 @@ public:
|
||||||
|
|
||||||
int32 ID() const { return fID; }
|
int32 ID() const { return fID; }
|
||||||
int32 ChangeCounter() const { return fChangeCounter.Count(); }
|
int32 ChangeCounter() const { return fChangeCounter.Count(); }
|
||||||
void Changed() { fChangeCounter.Increment(); }
|
// void Changed() { fChangeCounter.Increment(); }
|
||||||
|
void Changed() { if (fChangeCounter.Increment()) PRINT(("RDiskDevice::Changed()\n")); }
|
||||||
|
|
||||||
void SetTouched(bool touched) { fTouched = touched; }
|
void SetTouched(bool touched) { fTouched = touched; }
|
||||||
bool Touched() const { return fTouched; }
|
bool Touched() const { return fTouched; }
|
||||||
|
|
Loading…
Reference in New Issue