Giter Club home page Giter Club logo

csapp-3e-proxy-lab's Introduction

Proxy Lab

北京大学 2022 年秋季学期《计算机系统导论》课程 Proxy Lab。

编译

你需要使用 xmake 进行编译。

说明 (2024.3.2 更新)

进行了彻底的重构。

重构版本在 Basic、Concurrency 和 Caching 都能达到满分。Real Pages 部分 real-2048 失败。

但注意到如下情况:

  1. 重构前的版本,现在也过不了 real-2048
  2. 使用新版本作为代理,可以正常访问 bilibili 看视频。

可以推测:real-2048 这个测试点本身有问题。而我的 proxy 没有问题。

说明 (2024.2.21 更新)

实际上这个代码有很大的问题:

  1. socket.cpp 的多数函数都不够优雅,因为是从 CSAPP 抄来的。
  2. 停机清理不够优雅。
  3. 整个 RIO 都是不必要的,但是我却把它封装得非常池沼。
  4. proxy.cppdo_https_proxy() 中涉及到对 n 的判断:
n = read(fd_to_server, buf, lab::MAX_OBJECT_SIZE);
// ...
if (write(fd_to_client, buf, n) != n)
{
    lab::Close(fd_to_server);
    return;
}

注意,在特定条件下,write 即便执行成功,也可能写入少于 n 字节。然而我的 proxy 却会退出(悲)

不要碰 RIO!不要碰 RIO!

也许你可以参考 asio 库。

csapp-3e-proxy-lab's People

Contributors

elkeid-me avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.