2 * Copyright (C) ARM Limited 2014-2015. 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 "AnnotateListener.h"
13 #include "OlySocket.h"
15 static const char STREAMLINE_ANNOTATE_PARENT[] = "\0streamline-annotate-parent";
17 struct AnnotateClient {
22 AnnotateListener::AnnotateListener() : mClients(NULL), mSock(NULL), mUds(NULL) {
25 AnnotateListener::~AnnotateListener() {
31 void AnnotateListener::setup() {
32 mSock = new OlyServerSocket(8082);
33 mUds = new OlyServerSocket(STREAMLINE_ANNOTATE_PARENT, sizeof(STREAMLINE_ANNOTATE_PARENT), true);
36 int AnnotateListener::getSockFd() {
37 return mSock->getFd();
40 void AnnotateListener::handleSock() {
41 AnnotateClient *const client = new AnnotateClient();
42 client->fd = mSock->acceptConnection();
43 client->next = mClients;
47 int AnnotateListener::getUdsFd() {
51 void AnnotateListener::handleUds() {
52 AnnotateClient *const client = new AnnotateClient();
53 client->fd = mUds->acceptConnection();
54 client->next = mClients;
58 void AnnotateListener::close() {
60 mUds->closeServerSocket();
63 mSock->closeServerSocket();
65 while (mClients != NULL) {
66 ::close(mClients->fd);
67 AnnotateClient *next = mClients->next;
73 void AnnotateListener::signal() {
75 AnnotateClient **ptr = &mClients;
76 AnnotateClient *client = mClients;
77 while (client != NULL) {
78 if (write(client->fd, &ch, sizeof(ch)) != 1) {
80 AnnotateClient *next = client->next;
87 client = client->next;