summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/ExternalSource.cpp')
-rw-r--r--daemon/ExternalSource.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/daemon/ExternalSource.cpp b/daemon/ExternalSource.cpp
new file mode 100644
index 0000000..fe5824b
--- /dev/null
+++ b/daemon/ExternalSource.cpp
@@ -0,0 +1,56 @@
1/**
2 * Copyright (C) ARM Limited 2010-2014. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include "ExternalSource.h"
10
11#include <sys/prctl.h>
12
13#include "Logging.h"
14#include "OlySocket.h"
15#include "SessionData.h"
16
17ExternalSource::ExternalSource(sem_t *senderSem) : mBuffer(0, FRAME_EXTERNAL, 1024, senderSem), mSock("/tmp/gator") {
18}
19
20ExternalSource::~ExternalSource() {
21}
22
23bool ExternalSource::prepare() {
24 return true;
25}
26
27void ExternalSource::run() {
28 prctl(PR_SET_NAME, (unsigned long)&"gatord-uds", 0, 0, 0);
29
30 while (gSessionData->mSessionIsActive) {
31 // Will be aborted when the socket is closed at the end of the capture
32 int length = mSock.receive(mBuffer.getWritePos(), mBuffer.contiguousSpaceAvailable());
33 if (length <= 0) {
34 break;
35 }
36
37 mBuffer.advanceWrite(length);
38 mBuffer.check(0);
39 }
40
41 mBuffer.setDone();
42}
43
44void ExternalSource::interrupt() {
45 // Do nothing
46}
47
48bool ExternalSource::isDone() {
49 return mBuffer.isDone();
50}
51
52void ExternalSource::write(Sender *sender) {
53 if (!mBuffer.isDone()) {
54 mBuffer.write(sender);
55 }
56}