23 t.setNsNameValue(
"alloc",
"tmpid",
"*");
25 context.
setRid(db->find(
t,
nullptr));
27 t.setNsNameValue(
"alloc",
"*",
"free");
28 std::list<Triple> match = db->query(
t,&context);
30 name = match.begin()->name;
36 t.setNsNameValue(
"alloc",
"tmpid",
"*");
37 std::list<Triple> lst = db->query(
t,
nullptr);
39 tmpid = atoi(lst.begin()->value.c_str());
47 std::snprintf(buf, 256,
"%d", tmpid);
48 t.setNsNameValue(
"alloc",
"tmpid",buf);
49 db->update(
t,
nullptr);
50 t.setNsNameValue(
"alloc",
"tmpid",
"*");
51 context.
setRid(db->find(
t,
nullptr));
52 std::snprintf(buf, 256,
"/tmp/port/%u", tmpid);
56 t.setNsNameValue(
"alloc",name.c_str(),
"in_use");
57 db->update(
t,&context);
68 return completePortNumber(tmp);
87 t.setNsNameValue(
"alloc",
"regid",
"*");
89 context.
setRid(db->find(
t,
nullptr));
91 t.setNsNameValue(
"prefer",
"*",c.
getName().c_str());
92 std::list<Triple> match = db->query(
t,&context);
94 npref = match.begin()->name;
95 pref = atoi(npref.c_str());
96 t.setNsNameValue(
"alloc",npref.c_str(),
"in_use");
97 match = db->query(
t,&context);
98 if (match.size()==0) {
108 t.setNsNameValue(
"alloc",
"regid",
"*");
109 std::list<Triple> lst = db->query(
t,
nullptr);
111 regid = atoi(lst.begin()->value.c_str());
114 regid = config.minPortNumber-1;
117 if (regid>=config.maxPortNumber && config.maxPortNumber!=0) {
119 t.setNsNameValue(
"alloc",
"*",
"free");
120 std::list<Triple> match = db->query(
t,&context);
121 if (match.size()>0) {
122 nstring = match.begin()->name;
123 number = atoi(nstring.c_str());
127 yCError(ALLOCATORONTRIPLES,
"Ran out of port numbers");
128 yCError(ALLOCATORONTRIPLES,
"* Make sure ports/programs get closed properly.");
129 yCError(ALLOCATORONTRIPLES,
"* If programs terminate without closing ports, run \"yarp clean\" from time to time..");
136 std::snprintf(buf, 256,
"%d", regid);
137 t.setNsNameValue(
"alloc",
"regid",buf);
138 db->update(
t,
nullptr);
139 t.setNsNameValue(
"alloc",
"regid",
"*");
140 context.
setRid(db->find(
t,
nullptr));
145 t.setNsNameValue(
"alloc",nstring.c_str(),
"in_use");
146 db->update(
t,&context);
147 t.setNsNameValue(
"prefer",nstring.c_str(),c.
getName().c_str());
148 db->update(
t,&context);
168 t.setNsNameValue(
"alloc",
"mcastCursor",
"*");
170 context.
setRid(db->find(
t,
nullptr));
171 if (context.
rid>=0) {
172 t.setNsNameValue(
"alloc",
"*",
"free");
173 std::list<Triple> match = db->query(
t,&context);
174 if (match.size()>0) {
175 name = match.begin()->name;
180 if (mcastCursor==-1) {
181 t.setNsNameValue(
"alloc",
"mcastCursor",
"*");
182 std::list<Triple> lst = db->query(
t,
nullptr);
184 mcastCursor = atoi(lst.begin()->value.c_str());
186 if (mcastCursor==-1) {
192 std::snprintf(buf, 256,
"%d", mcastCursor);
193 t.setNsNameValue(
"alloc",
"mcastCursor",buf);
194 db->update(
t,
nullptr);
195 t.setNsNameValue(
"alloc",
"mcastCursor",
"*");
196 context.
setRid(db->find(
t,
nullptr));
198 int v1 = mcastCursor%255;
199 int v2 = mcastCursor/255;
201 yCError(ALLOCATORONTRIPLES,
"Ran out of mcast addresses");
204 std::snprintf(buf, 256,
"224.1.%d.%d", v2+1, v1+1);
208 t.setNsNameValue(
"alloc",name.c_str(),
"in_use");
209 db->update(
t,&context);
218 std::string portName = c.
getName();
220 std::string hostName = c.
getHost();
224 t.setNsNameValue(
"alloc",
"tmpid",
"*");
226 context.
setRid(db->find(
t,
nullptr));
227 t.setNsNameValue(
"alloc",portName.c_str(),
"in_use");
228 if (db->find(
t,&context)>=0) {
229 t.setNsNameValue(
"alloc",portName.c_str(),
"free");
230 db->update(
t,&context);
233 t.setNsNameValue(
"alloc",
"regid",
"*");
234 context.
setRid(db->find(
t,
nullptr));
236 std::snprintf(buf, 256,
"%d", portNumber);
237 t.setNsNameValue(
"alloc",buf,
"in_use");
238 if (db->find(
t,&context)>=0) {
239 t.setNsNameValue(
"alloc",buf,
"free");
240 db->update(
t,&context);
243 t.setNsNameValue(
"alloc",
"mcastCursor",
"*");
244 context.
setRid(db->find(
t,
nullptr));
245 t.setNsNameValue(
"alloc",hostName.c_str(),
"in_use");
246 if (db->find(
t,&context)>=0) {
247 t.setNsNameValue(
"alloc",hostName.c_str(),
"free");
248 db->update(
t,&context);
Side information for controlling access to triples.
The basic unit of data the name server works with.
#define yCError(component,...)
#define YARP_SERVERSQL_LOG_COMPONENT(name, name_string)
An interface to the operating system, including Port based communication.