2 * Copyright (C) ARM Limited 2010-2014. All rights reserved.
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.
9 #include "ExternalSource.h"
11 #include <sys/prctl.h>
14 #include "OlySocket.h"
15 #include "SessionData.h"
17 ExternalSource::ExternalSource(sem_t *senderSem) : mBuffer(0, FRAME_EXTERNAL, 1024, senderSem), mSock("/tmp/gator") {
20 ExternalSource::~ExternalSource() {
23 bool ExternalSource::prepare() {
27 void ExternalSource::run() {
28 prctl(PR_SET_NAME, (unsigned long)&"gatord-uds", 0, 0, 0);
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());
37 mBuffer.advanceWrite(length);
44 void ExternalSource::interrupt() {
48 bool ExternalSource::isDone() {
49 return mBuffer.isDone();
52 void ExternalSource::write(Sender *sender) {
53 if (!mBuffer.isDone()) {
54 mBuffer.write(sender);