Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #578 from spray/ticket/567
Browse files Browse the repository at this point in the history
Ticket/567
  • Loading branch information
sirthias committed Oct 8, 2013
2 parents 0f0fdd2 + 09834d6 commit 5ac8b64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.io.{ FileOutputStream, File }
class HttpDataRenderingSpec extends Specification {
val bytes = ByteString(Array.fill(10)('a'.toByte))
val file = {
val res = File.createTempFile("test", "dat")
val res = File.createTempFile("test", "dat").getCanonicalFile
val os = new FileOutputStream(res)
os.write(Array.fill(2000)('b'.toByte))
os.close()
Expand Down
15 changes: 14 additions & 1 deletion spray-can/src/main/scala/spray/can/server/ServerFrontend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package spray.can.server

import scala.annotation.tailrec
import scala.util.control.NonFatal
import scala.concurrent.duration.Duration
import akka.actor.ActorRef
Expand Down Expand Up @@ -124,7 +125,7 @@ private object ServerFrontend {
case x: AckEventWithReceiver
firstUnconfirmed = firstUnconfirmed handleSentAckAndReturnNextUnconfirmed x

case Tcp.CommandFailed(Tcp.Write(_, Tcp.NoAck(PartAndSender(part, responseSender))))
case Tcp.CommandFailed(WriteCommandWithLastAck(Tcp.NoAck(PartAndSender(part, responseSender))))
// TODO: implement automatic checkpoint buffering and write resuming
context.log.error("Could not write response part {}, closing connection", part)
commandPL(Pipeline.Tell(responseSender, Http.SendFailed(part), context.self))
Expand Down Expand Up @@ -159,4 +160,16 @@ private object ServerFrontend {
}
}
}

private object WriteCommandWithLastAck {
def unapply(cmd: Tcp.Command): Option[Event] = {
@tailrec def lastAck(c: Tcp.Command): Option[Event] =
c match {
case x: Tcp.SimpleWriteCommand Some(x.ack)
case Tcp.CompoundWrite(_, tail) lastAck(tail)
case _ None
}
lastAck(cmd)
}
}
}

0 comments on commit 5ac8b64

Please sign in to comment.