Skip to content

Commit d7538df

Browse files
authored
SpigotMC#3815: Ensure ping response for unthrottling
1 parent 2516de6 commit d7538df

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ private ServerPing getPingInfo(String motd, int protocol)
283283
public void handle(StatusRequest statusRequest) throws Exception
284284
{
285285
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
286+
thisState = null; // don't accept multiple status requests and set state to ping in async event callback
286287

287288
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
288289
final String motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
@@ -306,10 +307,7 @@ public void done(ProxyPingEvent pingResult, Throwable error)
306307
{
307308
Gson gson = PingHandler.gson;
308309
unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
309-
if ( bungee.getConnectionThrottle() != null )
310-
{
311-
bungee.getConnectionThrottle().unthrottle( getSocketAddress() );
312-
}
310+
thisState = State.PING;
313311
}
314312
};
315313

@@ -324,8 +322,6 @@ public void done(ProxyPingEvent pingResult, Throwable error)
324322
{
325323
pingBack.done( getPingInfo( motd, protocol ), null );
326324
}
327-
328-
thisState = State.PING;
329325
}
330326

331327
@Override
@@ -334,6 +330,10 @@ public void handle(PingPacket ping) throws Exception
334330
Preconditions.checkState( thisState == State.PING, "Not expecting PING" );
335331
unsafe.sendPacket( ping );
336332
disconnect( "" );
333+
if ( bungee.getConnectionThrottle() != null )
334+
{
335+
bungee.getConnectionThrottle().unthrottle( getSocketAddress() );
336+
}
337337
}
338338

339339
@Override

0 commit comments

Comments
 (0)