Skip to content

Fix Fragmentaion Issue - #29

Closed
razimograbi wants to merge 2 commits into
mainfrom
fix_fragmentation_issues
Closed

Fix Fragmentaion Issue#29
razimograbi wants to merge 2 commits into
mainfrom
fix_fragmentation_issues

Conversation

@razimograbi

@razimograbi razimograbi commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

related to issue: #13

I replaced the standard epoll logic with EPOLLONESHOT.

image image

In order to test the fragmentation run the server on debug mode and then open PowerShell and past this command:

$client = New-Object System.Net.Sockets.TcpClient("localhost", 6625)
$stream = $client.GetStream()
$writer = New-Object System.IO.StreamWriter($stream)

while ($true) {
    Write-Host -NoNewline "> "
    $cmd = [Console]::ReadLine()
    
    # Converts literal '\n' to real newline byte (0x0A) and '\r' to carriage return (0x0D)
    $parsed = $cmd.Replace('\n', "`n").Replace('\r', "`r")
    
    $writer.Write($parsed)
    $writer.Flush()
}

Start sending inputs and then at the end add a \n so we can actually see that it works.

Related issue

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / internal change
  • Documentation
  • Build / CI

How was this tested?

Checklist

  • Code builds locally (cmake --build build)
  • Tests pass (ctest --test-dir build)
  • Added/updated tests for the change
  • Updated documentation if needed
  • Follows the project's header-guard / .h-.cpp split / Doxygen-comment conventions

@razimograbi razimograbi self-assigned this Jul 26, 2026
@razimograbi
razimograbi force-pushed the fix_fragmentation_issues branch from de579c6 to fddf4a2 Compare July 26, 2026 16:29
@razimograbi razimograbi changed the title remove busy_socket and busy_mutex, replaced with EPOLLONESHOT Fix Fragmentaion Issue Jul 26, 2026
@razimograbi razimograbi added the enhancement New feature or request label Jul 26, 2026
@razimograbi
razimograbi marked this pull request as draft July 26, 2026 16:33
Comment thread src/Server/Server.cpp
Comment on lines +235 to +238
if (clientConnection->commandBuffer.find('\n') == std::string::npos) {
this->rearmSocket(clientSocket);
return;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure if we can simply check the last character and that's it. hmmmm,
Can the command buffer be populated by other thread ? Because we are using EPOLLONESHOT I don't think so.
Might be able to optimize it to O(1)
@Ataba29

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not *

@razimograbi
razimograbi marked this pull request as ready for review July 27, 2026 07:41
@razimograbi
razimograbi requested a review from Ataba29 July 27, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant