Skip to content

Commit 87af88b

Browse files
committed
MAX_SEARCH_PAYLOAD
1 parent 40ae7e2 commit 87af88b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/pva/src/main/java/org/epics/pva/client/ChannelSearch.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ private class SearchedChannel
146146
/** Buffer for assembling search messages */
147147
private final ByteBuffer send_buffer = ByteBuffer.allocate(PVASettings.MAX_UDP_UNFRAGMENTED_SEND);
148148

149+
/** After header of about 50 bytes, allow this for the search packet payload (CIDs, names) */
150+
private final int MAX_SEARCH_PAYLOAD = PVASettings.MAX_UDP_UNFRAGMENTED_SEND - 50;
151+
149152
/** Address list to which search requests are sent */
150153
private final List<AddressInfo> unicast_search_addresses = new ArrayList<>(),
151154
b_or_mcast_search_addresses = new ArrayList<>(),
@@ -345,19 +348,22 @@ private void runSearches()
345348
{
346349
final PVAChannel channel = to_search.get(start + count);
347350
int size = 4 + PVAString.getEncodedSize(channel.getName());
348-
if (payload + size < 50) // TODO 1400
351+
if (payload + size < MAX_SEARCH_PAYLOAD)
349352
{
350353
++count;
351354
payload += size;
352355
}
353356
else if (count == 0)
354-
{
357+
{ // Can't fit this single name?
355358
logger.log(Level.WARNING, "PV name exceeds search buffer size: " + channel);
356359
searched_channels.remove(channel.getCID());
357360
to_search.remove(start + count);
358361
}
359362
else
363+
{
364+
logger.log(Level.FINER, () -> "Reached " + MAX_SEARCH_PAYLOAD + " bytes, splitting");
360365
break;
366+
}
361367
}
362368
if (count == 0)
363369
break;

0 commit comments

Comments
 (0)