[PR #2509] [MERGED] handle race condition while setting raw mode in windows #9654

Closed
opened 2025-11-12 15:11:10 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2509
Author: @pdevine
Created: 2/15/2024
Status: Merged
Merged: 2/15/2024
Merged by: @pdevine

Base: mainHead: winsyscall


📝 Commits (2)

  • 1514f4a handle race condition while setting raw mode in windows
  • e3048ba lint

📊 Changes

5 files changed (+38 additions, -15 deletions)

View changed files

📝 readline/readline.go (+28 -8)
📝 readline/readline_unix.go (+3 -2)
📝 readline/readline_windows.go (+1 -1)
📝 readline/term.go (+3 -2)
📝 readline/term_windows.go (+3 -2)

📄 Description

This change handles a race condition in the go routine which handles reading in runes. On Windows "raw mode" (i.e. turning off echo/line/processed input) gets turned off too late which would cause ReadRune() to wait until the buffer was full (when it got a new line). This change goes into raw mode faster, but it still needs to happen before any input since we turn it back off again once we start processing output.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/2509 **Author:** [@pdevine](https://github.com/pdevine) **Created:** 2/15/2024 **Status:** ✅ Merged **Merged:** 2/15/2024 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `winsyscall` --- ### 📝 Commits (2) - [`1514f4a`](https://github.com/ollama/ollama/commit/1514f4a26ad975fd55878f0ceff7a5782c224d1f) handle race condition while setting raw mode in windows - [`e3048ba`](https://github.com/ollama/ollama/commit/e3048bae2700435383282a49759d39f3c599c9c3) lint ### 📊 Changes **5 files changed** (+38 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `readline/readline.go` (+28 -8) 📝 `readline/readline_unix.go` (+3 -2) 📝 `readline/readline_windows.go` (+1 -1) 📝 `readline/term.go` (+3 -2) 📝 `readline/term_windows.go` (+3 -2) </details> ### 📄 Description This change handles a race condition in the go routine which handles reading in runes. On Windows "raw mode" (i.e. turning off echo/line/processed input) gets turned off too late which would cause `ReadRune()` to wait until the buffer was full (when it got a new line). This change goes into raw mode faster, but it still needs to happen before any input since we turn it back off again once we start processing output. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-12 15:11:10 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#9654